-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
4 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import psl from "psl"; | ||
import { parse } from "tldts"; | ||
export function rootDomain(url: string) { | ||
let parsed = psl.parse(url); | ||
if (parsed.error) return null; | ||
let parsed = parse(url); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
boehs
Author
Member
|
||
if ( | ||
parsed.subdomain && | ||
[ | ||
|
@@ -19,7 +18,7 @@ export function rootDomain(url: string) { | |
"zh", | ||
].includes(parsed.subdomain) | ||
) | ||
return parsed.sld; | ||
return parsed.domainWithoutSuffix; | ||
// honestly just always return the sld | ||
return parsed.sld; | ||
return parsed.domainWithoutSuffix; | ||
} |
Hey, by default
tldts.parse
will ignore the private section of the public suffix list. If that's important for your use-case you may enable it with an additional option: