Housekeeping
Some checks failed
Build / Build (push) Has been cancelled
Build / Diff output (push) Has been cancelled
Build / Deploy to Cloudflare Pages (3.114.12) (push) Has been cancelled
Build / Deploy to GitHub and GitLab (push) Has been cancelled

This commit is contained in:
SukkaW
2025-10-25 14:57:28 +08:00
parent 12d56e27f1
commit f1cc4e21d5
7 changed files with 125 additions and 122 deletions

View File

@@ -23,10 +23,10 @@ const pool = new Worktank({
autoInstantiate: true,
methods: {
// eslint-disable-next-line object-shorthand -- workertank
getS3OSSDomains: async function (importMetaUrl: string): Promise<string[]> {
getS3OSSDomains: async function (__filename: string): Promise<string[]> {
// TODO: createRequire is a temporary workaround for https://github.com/nodejs/node/issues/51956
const { default: module } = await import('node:module');
const __require = module.createRequire(importMetaUrl);
const __require = module.createRequire(__filename);
const { HostnameTrie } = __require('./lib/trie') as typeof import('./lib/trie');
const { fetchRemoteTextByLine } = __require('./lib/fetch-text-by-line') as typeof import('./lib/fetch-text-by-line');
@@ -81,7 +81,7 @@ export const buildCdnDownloadConf = task(require.main === module, __filename)(as
] = await Promise.all([
span.traceChildAsync('download public suffix list for s3', () => pool.exec(
'getS3OSSDomains',
[import.meta.url]
[__filename]
).finally(() => pool.terminate())),
cdnDomainsListPromise,
downloadDomainSetPromise,

View File

@@ -15,11 +15,11 @@ const pool = new Worktank({
autoTerminate: 30000, // The interval of milliseconds at which to check if the pool can be automatically terminated, to free up resources, workers will be spawned up again if needed
autoInstantiate: true,
methods: {
// eslint-disable-next-line object-shorthand -- workertank
getMicrosoftCdnRuleset: async function (importMetaUrl: string): Promise<[domains: string[], domainSuffixes: string[]]> {
// eslint-disable-next-line object-shorthand -- workertank
getMicrosoftCdnRuleset: async function (__filename: string): Promise<[domains: string[], domainSuffixes: string[]]> {
// TODO: createRequire is a temporary workaround for https://github.com/nodejs/node/issues/51956
const { default: module } = await import('node:module');
const __require = module.createRequire(importMetaUrl);
const __require = module.createRequire(__filename);
const { HostnameSmolTrie } = __require('./lib/trie');
const { PROBE_DOMAINS, DOMAINS, DOMAIN_SUFFIXES, BLACKLIST } = __require('./constants/microsoft-cdn') as typeof import('./constants/microsoft-cdn');
@@ -51,7 +51,7 @@ const pool = new Worktank({
export const getMicrosoftCdnRulesetPromise = once<Promise<[domains: string[], domainSuffixes: string[]]>>(async () => {
const res = await pool.exec(
'getMicrosoftCdnRuleset',
[import.meta.url]
[__filename]
);
pool.terminate();

View File

@@ -4,7 +4,7 @@ import { compareAndWriteFile } from './lib/create-file';
import { getHostname } from 'tldts-experimental';
import { isTruthy } from 'foxts/guard';
import { OUTPUT_MODULES_DIR } from './constants/dir';
import { escapeStringRegexp } from 'foxts/escape-string-regexp';
import { escapeRegexp } from 'fast-escape-regexp';
const REDIRECT_MIRROR_HEADER = [
// Gravatar
@@ -163,9 +163,9 @@ export const buildRedirectModule = task(require.main === module, __filename)(asy
`hostname = %APPEND% ${domains.join(', ')}`,
'',
'[URL Rewrite]',
...REDIRECT_MIRROR_HEADER.map(([from, to]) => `^https?://${escapeStringRegexp(from)}(.*) ${to}$1 header`),
...REDIRECT_MIRROR_HEADER.map(([from, to]) => `^https?://${escapeRegexp(from)}(.*) ${to}$1 header`),
...REDIRECT_FAKEWEBSITES.map(([from, to]) => `^https?://(www.)?${(from)} ${to} 307`),
...REDIRECT_MIRROR_307.map(([from, to]) => `^https?://${escapeStringRegexp(from)}(.*) ${to}$1 307`)
...REDIRECT_MIRROR_307.map(([from, to]) => `^https?://${escapeRegexp(from)}(.*) ${to}$1 307`)
],
path.join(OUTPUT_MODULES_DIR, 'sukka_url_redirect.sgmodule')
);

View File

@@ -204,7 +204,7 @@ export function getPhishingDomains(parentSpan: Span) {
const phishingDomains = await pool.exec(
'getPhishingDomains',
[
import.meta.url,
__filename,
require.main === module
]
);

View File

@@ -1,7 +1,7 @@
import { escapeStringRegexp } from 'foxts/escape-string-regexp';
import { BaseWriteStrategy } from './base';
import { noop } from 'foxts/noop';
import { notSupported } from '../misc';
import { escapeRegexp } from 'fast-escape-regexp';
export class AdGuardHome extends BaseWriteStrategy {
public readonly name = 'adguardhome';
@@ -48,7 +48,7 @@ export class AdGuardHome extends BaseWriteStrategy {
writeDomainKeywords(keywords: Set<string>): void {
for (const keyword of keywords) {
// Use regex to match keyword
this.result.push(`/${escapeStringRegexp(keyword, false)}/`);
this.result.push(`/${escapeRegexp(keyword, false)}/`);
}
}