File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,13 @@ interface ParseOptions {
1010 * @note This option can also be used when parsing URLs that contain IP addresses.
1111 */
1212 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 ;
1320}
1421
1522interface ParseResult {
Original file line number Diff line number Diff line change @@ -14,6 +14,13 @@ expectType<ParseResult>(parse_url("", { allowUnknownTLD: true }));
1414expectType < ParseResult > (
1515 parse_url ( "" , { allowPrivateTLD : true , allowUnknownTLD : true } )
1616) ;
17+ expectType < ParseResult > (
18+ parse_url ( "" , {
19+ allowPrivateTLD : true ,
20+ allowUnknownTLD : true ,
21+ allowDotlessTLD : true ,
22+ } )
23+ ) ;
1724
1825expectType < ParseResult > ( parse_host ( "" ) ) ;
1926expectType < ParseResult > ( parse_host ( "" , { } ) ) ;
@@ -22,6 +29,13 @@ expectType<ParseResult>(parse_host("", { allowUnknownTLD: true }));
2229expectType < ParseResult > (
2330 parse_host ( "" , { allowPrivateTLD : true , allowUnknownTLD : true } )
2431) ;
32+ expectType < ParseResult > (
33+ parse_host ( "" , {
34+ allowPrivateTLD : true ,
35+ allowUnknownTLD : true ,
36+ allowDotlessTLD : true ,
37+ } )
38+ ) ;
2539
2640expectError < ParseResult > ( parse_url ( ) ) ;
2741expectError < ParseResult > ( parse_url ( { } ) ) ;
@@ -30,11 +44,16 @@ expectError<ParseResult>(parse_host({}));
3044
3145const testUrl = "https://github.com/131/node-tld/blob/master/index.js" ;
3246const testHostname = "github.com" ;
33- const testOptions = { allowPrivateTLD : true , allowUnknownTLD : true } ;
47+ const testOptions = {
48+ allowPrivateTLD : true ,
49+ allowUnknownTLD : true ,
50+ allowDotlessTLD : true ,
51+ } ;
3452
3553interface ParseOptions {
3654 allowPrivateTLD ?: boolean ;
3755 allowUnknownTLD ?: boolean ;
56+ allowDotlessTLD ?: boolean ;
3857}
3958
4059expectAssignable < string > ( testUrl ) ;
You can’t perform that action at this time.
0 commit comments