char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Aleksander Grygierui: Stores split refactor (#27240)521a64cd0

char/aliceai-t5-moe
3.2 KiB192 linesraw
1import { UrlProtocol } from '$lib/enums';
2
3const STD = ['com', 'net', 'org', 'gov', 'edu'] as const;
4const STD_MIL = [...STD, 'mil'] as const;
5const ccTLD_PREFIXES: Record<string, readonly string[]> = {
6	ae: ['co', 'net', 'org', 'gov', 'ac', 'sch'],
7	// --- Standard 5 only ---
8	ar: STD,
9	au: [...STD_MIL, 'id', 'asn', 'csiro'],
10	bd: STD,
11	bg: STD,
12	br: [
13		...STD_MIL,
14		'art',
15		'eco',
16		'eng',
17		'inf',
18		'med',
19		'psi',
20		'tmp',
21		'etc',
22		'adm',
23		'adv',
24		'arq',
25		'bio',
26		'bmd',
27		'cim',
28		'cng',
29		'cnt',
30		'coop',
31		'ecn',
32		'esp',
33		'far',
34		'fm',
35		'fnd',
36		'fot',
37		'fst',
38		'g12',
39		'ggf',
40		'imb',
41		'ind',
42		'jor',
43		'jus',
44		'leg',
45		'lel',
46		'mat',
47		'mp',
48		'mus',
49		'not',
50		'ntr',
51		'odo',
52		'ppg',
53		'pro',
54		'psc',
55		'qsl',
56		'rec',
57		'slg',
58		'srv',
59		'trd',
60		'tur',
61		'tv',
62		'vet',
63		'vlog',
64		'wiki',
65		'zlg'
66	],
67	cn: STD_MIL,
68	eg: STD,
69	gr: STD,
70	hk: STD,
71	hr: STD,
72	hu: ['co', 'net', 'org', 'gov', 'edu'],
73	id: [...STD_MIL, 'co', 'go', 'or', 'web', 'sch'],
74	il: ['co', 'net', 'org', 'gov', 'ac', 'muni'],
75	in: [...STD_MIL, 'co', 'gen', 'ind', 'firm', 'ernet', 'nic'],
76	jp: ['ac', 'ad', 'co', 'ed', 'go', 'gr', 'lg', 'ne', 'or'],
77	ke: ['co', 'or', 'ne', 'go', 'ac', 'sc'],
78	kr: [...STD_MIL, 'co', 'go', 'or', 'ac', 're'],
79	lk: STD,
80	mx: STD_MIL,
81	my: STD_MIL,
82	ng: STD,
83	nz: [
84		...STD_MIL,
85		'co',
86		'gen',
87		'geek',
88		'kiwi',
89		'maori',
90		'school',
91		'govt',
92		'health',
93		'iwi',
94		'parliament'
95	],
96
97	ph: STD,
98	pk: STD,
99	pl: STD,
100	ro: STD,
101	rs: ['co', 'net', 'org', 'gov', 'edu'],
102	ru: STD,
103	sa: STD,
104	sg: [...STD, 'per'],
105
106	si: STD,
107	th: ['co', 'go', 'or', 'in', 'ac', 'mi', 'net'],
108	tr: STD,
109	tw: STD,
110	ua: STD,
111	uk: ['co', 'org', 'net', 'ac', 'gov', 'mil', 'nhs', 'police', 'mod', 'ltd', 'plc', 'me', 'sch'],
112	ve: STD,
113	za: ['co', 'org', 'net', 'web', 'law', 'mil']
114};
115const WILDCARD_BASES: Record<string, readonly string[]> = {
116	br: ['nom', 'blog'],
117	jp: [
118		'kobe',
119		'kyoto',
120		'nagoya',
121		'osaka',
122		'sapporo',
123		'sendai',
124		'tokyo',
125		'yokohama',
126		'aichi',
127		'akita',
128		'aomori',
129		'chiba',
130		'ehime',
131		'fukui',
132		'fukuoka',
133		'fukushima',
134		'gifu',
135		'gunma',
136		'hiroshima',
137		'hokkaido',
138		'hyogo',
139		'ibaraki',
140		'ishikawa',
141		'iwate',
142		'kagawa',
143		'kagoshima',
144		'kanagawa',
145		'kochi',
146		'kumamoto',
147		'mie',
148		'miyagi',
149		'miyazaki',
150		'nagano',
151		'nara',
152		'niigata',
153		'oita',
154		'okayama',
155		'okinawa',
156		'saga',
157		'saitama',
158		'shiga',
159		'shimane',
160		'shizuoka',
161		'tochigi',
162		'tokushima',
163		'tottori',
164		'toyama',
165		'wakayama',
166		'yamagata',
167		'yamaguchi',
168		'yamanashi'
169	]
170};
171
172function buildSuffixSet(suffixes: Record<string, readonly string[]>): Set<string> {
173	const set = new Set<string>();
174
175	for (const [tld, parts] of Object.entries(suffixes)) {
176		for (const part of parts) {
177			set.add(`${part}.${tld}`);
178		}
179	}
180
181	return set;
182}
183
184export const TWO_PART_PUBLIC_SUFFIXES = buildSuffixSet(ccTLD_PREFIXES);
185export const WILDCARD_PUBLIC_SUFFIXES = buildSuffixSet(WILDCARD_BASES);
186
187// Matches one or more trailing "/" characters at the end of a URL/path.
188export const TRAILING_SLASHES_REGEX = /\/+$/;
189
190// Protocols that apiFetch treats as absolute and passes through untouched.
191// Add a protocol here when a caller needs to fetch an absolute URL with it.
192export const API_ABSOLUTE_URL_PROTOCOLS = [UrlProtocol.HTTP, UrlProtocol.HTTPS] as const;