Skip to content

Commit

Permalink
psl → tldts closes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
boehs committed Jul 16, 2024
1 parent bedba32 commit c778d12
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions server/helpers/root-domain.ts
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.

Copy link
@remusao

remusao Jul 26, 2024

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:

  let parsed = parse(url, { allowPrivateDomains: true });

This comment has been minimized.

Copy link
@boehs

boehs Aug 1, 2024

Author Member

Thank you, I appreciate you seeking out this commit to let me know!!

if (
parsed.subdomain &&
[
Expand All @@ -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;
}

0 comments on commit c778d12

Please sign in to comment.