fix: TLD list

add: i18n of prompt text of link suggestion
This commit is contained in:
alikia2x (寒寒) 2025-01-20 04:49:09 +08:00
parent 42cc96a0e3
commit 2810c2f324
Signed by: alikia2x
GPG Key ID: 56209E0CCD8420C6
9 changed files with 15 additions and 1455 deletions

View File

@ -89,7 +89,7 @@ export default function OneSearch() {
type: "default-link", type: "default-link",
suggestion: query, suggestion: query,
relevance: 3000, relevance: 3000,
prompt: <span>Go to: </span> prompt: <span>{t('search.goto-help-text')}</span>
}, },
{ type: "default", suggestion: query, relevance: 1600 } { type: "default", suggestion: query, relevance: 1600 }
]); ]);

View File

@ -14,7 +14,8 @@
"yahoo": "Yahoo", "yahoo": "Yahoo",
"ecosia": "Ecosia" "ecosia": "Ecosia"
}, },
"search-help-text": "Search {engine}" "search-help-text": "Search {engine}",
"goto-help-text": "Go to: "
}, },
"notfound": { "notfound": {
"title": "page not found", "title": "page not found",

View File

@ -14,7 +14,8 @@
"yahoo": "雅虎", "yahoo": "雅虎",
"ecosia": "Ecosia" "ecosia": "Ecosia"
}, },
"search-help-text": "用 {engine} 搜索" "search-help-text": "用 {engine} 搜索",
"goto-help-text": "前往: "
}, },
"tools": { "tools": {
"base64": { "base64": {

View File

@ -1,5 +1,7 @@
import TLDtxt from "./tlds.txt"; import * as data from "./tlds.json";
export function getTLD() { export function getTLD() {
return TLDtxt.split("\r\n").filter((line) => line[0] !== "#"); return data.data;
} }
console.log(getTLD());

1
lib/url/tlds.json Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,5 @@
const response = await fetch("https://data.iana.org/TLD/tlds-alpha-by-domain.txt"); const response = await fetch("https://data.iana.org/TLD/tlds-alpha-by-domain.txt");
const tldText = await response.text(); const TLDtxt = await response.text();
await Bun.write("./lib/url/tlds.txt", tldText); const TLDdata = TLDtxt.split("\n").filter((line) => line[0] !== "#");
await Bun.write("./lib/url/tlds.json", JSON.stringify({"data": TLDdata}));

View File

@ -1,8 +1,6 @@
import { toASCII } from "tr46"; import { toASCII } from "tr46";
import { getTLD } from "./tldList"; import { getTLD } from "./tldList";
console.log(getTLD());
export default function validLink(link: string) { export default function validLink(link: string) {
let finalURL; let finalURL;
try { try {

View File

@ -9,6 +9,7 @@
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "NODE_ENV=production bun server.ts", "preview": "NODE_ENV=production bun server.ts",
"license-gen": "bunx generate-license-file --input package.json --output lib/license.txt --overwrite", "license-gen": "bunx generate-license-file --input package.json --output lib/license.txt --overwrite",
"update-tld": "bun lib/url/updateTLD.ts",
"format": "prettier --write ." "format": "prettier --write ."
}, },
"dependencies": { "dependencies": {