File tree 2 files changed +27
-1
lines changed
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,13 @@ interface ParseOptions {
10
10
* @note This option can also be used when parsing URLs that contain IP addresses.
11
11
*/
12
12
allowUnknownTLD ?: boolean ;
13
+ /**
14
+ * Allow parsing URLs that contain a top-level domain (TLD) used as a direct domain name,
15
+ * also known as a dotless domain.
16
+ *
17
+ * @note Using dotless domains is highly not recommended by ICANN and IAB. Use with caution.
18
+ */
19
+ allowDotlessTLD ?: boolean ;
13
20
}
14
21
15
22
interface ParseResult {
Original file line number Diff line number Diff line change @@ -14,6 +14,13 @@ expectType<ParseResult>(parse_url("", { allowUnknownTLD: true }));
14
14
expectType < ParseResult > (
15
15
parse_url ( "" , { allowPrivateTLD : true , allowUnknownTLD : true } )
16
16
) ;
17
+ expectType < ParseResult > (
18
+ parse_url ( "" , {
19
+ allowPrivateTLD : true ,
20
+ allowUnknownTLD : true ,
21
+ allowDotlessTLD : true ,
22
+ } )
23
+ ) ;
17
24
18
25
expectType < ParseResult > ( parse_host ( "" ) ) ;
19
26
expectType < ParseResult > ( parse_host ( "" , { } ) ) ;
@@ -22,6 +29,13 @@ expectType<ParseResult>(parse_host("", { allowUnknownTLD: true }));
22
29
expectType < ParseResult > (
23
30
parse_host ( "" , { allowPrivateTLD : true , allowUnknownTLD : true } )
24
31
) ;
32
+ expectType < ParseResult > (
33
+ parse_host ( "" , {
34
+ allowPrivateTLD : true ,
35
+ allowUnknownTLD : true ,
36
+ allowDotlessTLD : true ,
37
+ } )
38
+ ) ;
25
39
26
40
expectError < ParseResult > ( parse_url ( ) ) ;
27
41
expectError < ParseResult > ( parse_url ( { } ) ) ;
@@ -30,11 +44,16 @@ expectError<ParseResult>(parse_host({}));
30
44
31
45
const testUrl = "https://github.com/131/node-tld/blob/master/index.js" ;
32
46
const testHostname = "github.com" ;
33
- const testOptions = { allowPrivateTLD : true , allowUnknownTLD : true } ;
47
+ const testOptions = {
48
+ allowPrivateTLD : true ,
49
+ allowUnknownTLD : true ,
50
+ allowDotlessTLD : true ,
51
+ } ;
34
52
35
53
interface ParseOptions {
36
54
allowPrivateTLD ?: boolean ;
37
55
allowUnknownTLD ?: boolean ;
56
+ allowDotlessTLD ?: boolean ;
38
57
}
39
58
40
59
expectAssignable < string > ( testUrl ) ;
You can’t perform that action at this time.
0 commit comments