mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-28 17:41:54 +08:00
Housekeeping
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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')
|
||||
);
|
||||
|
||||
@@ -204,7 +204,7 @@ export function getPhishingDomains(parentSpan: Span) {
|
||||
const phishingDomains = await pool.exec(
|
||||
'getPhishingDomains',
|
||||
[
|
||||
import.meta.url,
|
||||
__filename,
|
||||
require.main === module
|
||||
]
|
||||
);
|
||||
|
||||
@@ -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)}/`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user