File tree 4 files changed +40
-11
lines changed
4 files changed +40
-11
lines changed Original file line number Diff line number Diff line change 44
44
"cross-spawn" : " 7.0.6" ,
45
45
"follow-redirects" : " 1.15.9" ,
46
46
"fs-extra" : " 11.2.0" ,
47
- "is-valid-domain" : " 0.1.6" ,
48
47
"log4js" : " 6.9.1" ,
49
48
"strip-ansi" : " 6.0.1" ,
50
- "uuid" : " 9.0.1"
49
+ "uuid" : " 9.0.1" ,
50
+ "validator" : " 13.12.0"
51
51
},
52
52
"devDependencies" : {
53
53
"@types/follow-redirects" : " 1.14.4" ,
54
54
"@types/fs-extra" : " 11.0.4" ,
55
55
"@types/uuid" : " 9.0.8" ,
56
+ "@types/validator" : " 13.12.2" ,
56
57
"@typescript-eslint/eslint-plugin" : " 4.33.0" ,
57
58
"@typescript-eslint/parser" : " 4.33.0" ,
58
59
"eslint-config-prettier" : " 8.10.0" ,
Original file line number Diff line number Diff line change
1
+ import { isRegistryModule } from "./terraform-module" ;
2
+
3
+ describe ( "terraform-module" , ( ) => {
4
+ describe . each `
5
+ source | expected
6
+ ${ "hashicorp/consul/aws" } | ${ true }
7
+ ${ "hashicorp/consul/aws//foo" } | ${ false }
8
+ ${ "./consul" } | ${ false }
9
+ ${ "[email protected] :hashicorp/example.git" } | ${ false }
10
+ ${ "github.com/hashicorp/example" } | ${ false }
11
+ ${ "github.com/hashicorp/terraform-cidr-subnets" } | ${ false }
12
+ ${ "bitbucket.org/hashicorp/terraform-consul-aws" } | ${ false }
13
+ ${ "foo/var/baz/qux" } | ${ false }
14
+ ${ "foo.com/var/baz" } | ${ true }
15
+ ${ ".foo.com/var/baz" } | ${ false }
16
+ ${ "f-o-o.com/var/baz" } | ${ true }
17
+ ${ "foo.com/var/baz/canz" } | ${ true }
18
+ ${ "example.com/awesomecorp/network/happycloud//examples/foo" } | ${ false }
19
+ ${ "www.googleapis.com/storage/v1/BUCKET_NAME/PATH_TO_MODULE" } | ${ false }
20
+ ` ( "isRegistryModule($source)" , ( { source, expected } ) => {
21
+ it ( `expects ${ expected } ` , ( ) => {
22
+ expect ( isRegistryModule ( source ) ) . toBe ( expected ) ;
23
+ } ) ;
24
+ } ) ;
25
+ } ) ;
Original file line number Diff line number Diff line change 1
1
// Copyright (c) HashiCorp, Inc
2
2
// SPDX-License-Identifier: MPL-2.0
3
- import isValidDomain from "is-valid-domain " ;
3
+ import { isFQDN } from "validator " ;
4
4
5
5
// Logic from https://github.com/hashicorp/terraform/blob/e09b831f6ee35d37b11b8dcccd3a6d6f6db5e5ff/internal/addrs/module_source.go#L198
6
6
export function isRegistryModule ( source : string ) {
@@ -15,7 +15,7 @@ export function isRegistryModule(source: string) {
15
15
return false ;
16
16
}
17
17
18
- if ( parts . length === 4 && ! isValidDomain ( parts [ 0 ] ) ) {
18
+ if ( parts . length === 4 && ! isFQDN ( parts [ 0 ] ) ) {
19
19
return false ;
20
20
}
21
21
Original file line number Diff line number Diff line change 2405
2405
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-9.0.8.tgz#7545ba4fc3c003d6c756f651f3bf163d8f0f29ba"
2406
2406
integrity sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==
2407
2407
2408
+
2409
+ version "13.12.2"
2410
+ resolved "https://registry.yarnpkg.com/@types/validator/-/validator-13.12.2.tgz#760329e756e18a4aab82fc502b51ebdfebbe49f5"
2411
+ integrity sha512-6SlHBzUW8Jhf3liqrGGXyTJSIFe4nqlJ5A5KaMZ2l/vbM3Wh3KSybots/wfWVzNLK4D1NZluDlSQIbIEPx6oyA==
2412
+
2408
2413
"@types/wrap-ansi@^3.0.0":
2409
2414
version "3.0.0"
2410
2415
resolved "https://registry.yarnpkg.com/@types/wrap-ansi/-/wrap-ansi-3.0.0.tgz#18b97a972f94f60a679fd5c796d96421b9abb9fd"
@@ -6930,13 +6935,6 @@ is-upper-case@^2.0.2:
6930
6935
dependencies:
6931
6936
tslib "^2.0.3"
6932
6937
6933
-
6934
- version "0.1.6"
6935
- resolved "https://registry.yarnpkg.com/is-valid-domain/-/is-valid-domain-0.1.6.tgz#3c85469d2938f170c8f82ce6e52df8ad9fca8105"
6936
- integrity sha512-ZKtq737eFkZr71At8NxOFcP9O1K89gW3DkdrGMpp1upr/ueWjj+Weh4l9AI4rN0Gt8W2M1w7jrG2b/Yv83Ljpg==
6937
- dependencies:
6938
- punycode "^2.1.1"
6939
-
6940
6938
is-weakmap@^2.0.2:
6941
6939
version "2.0.2"
6942
6940
resolved "https://registry.yarnpkg.com/is-weakmap/-/is-weakmap-2.0.2.tgz#bf72615d649dfe5f699079c54b83e47d1ae19cfd"
@@ -12230,6 +12228,11 @@ validate-npm-package-name@^5.0.0:
12230
12228
dependencies:
12231
12229
builtins "^5.0.0"
12232
12230
12231
+
12232
+ version "13.12.0"
12233
+ resolved "https://registry.yarnpkg.com/validator/-/validator-13.12.0.tgz#7d78e76ba85504da3fee4fd1922b385914d4b35f"
12234
+ integrity sha512-c1Q0mCiPlgdTVVVIJIrBuxNicYE+t/7oKeI9MWLj3fh/uq2Pxh/3eeWbVZ4OcGW1TUf53At0njHw5SMdA3tmMg==
12235
+
12233
12236
w3c-hr-time@^1.0.2:
12234
12237
version "1.0.2"
12235
12238
resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz#0a89cdf5cc15822df9c360543676963e0cc308cd"
You can’t perform that action at this time.
0 commit comments