Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(deps): replace psl with tldts #790

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"lucide-react": "^0.302.0",
"md5.js": "^1.3.5",
"plasmo": "0.84.0",
"psl": "^1.9.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hot-toast": "^2.4.1",
Expand All @@ -36,6 +35,7 @@
"rss-parser": "3.13.0",
"tailwind-merge": "^2.2.0",
"tailwindcss-animate": "^1.0.7",
"tldts": "^6.1.1",
"usehooks-ts": "^2.9.1",
"xss": "1.0.14"
},
Expand Down
21 changes: 14 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/lib/rsshub.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import psl from 'psl';
import { parse } from 'tldts';
import RouteRecognizer from 'route-recognizer';
import { parseRules } from './rules';
import type { Rule, RSSData } from './types';
Expand Down Expand Up @@ -78,7 +78,7 @@ export function getPageRSSHub(data: {

let parsedDomain;
try {
parsedDomain = psl.parse(new URL(url).hostname);
parsedDomain = parse(new URL(url).hostname);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: salesforce/tough-cookie#346 (comment)

Some of these might be relevant depending on your use-case. There are slight differences in default behavior between psl and tldts.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much, private domains will not be used in our extension, so there is no problem.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to shrink the bundle size a bit, there is a version of tldts that only ships with ICANN rules: https://github.com/remusao/tldts/tree/master/packages/tldts-icann#tldts---blazing-fast-url-parsing-icann-rules-only

} catch (error) {
return [];
}
Expand Down Expand Up @@ -186,7 +186,7 @@ export function getWebsiteRSSHub(data: {
const rules = parseRules(data.rules);
let parsedDomain;
try {
parsedDomain = psl.parse(new URL(url).hostname);
parsedDomain = parse(new URL(url).hostname);
} catch (error) {
return [];
}
Expand Down