Housekeeping & Make ESLint Happy

This commit is contained in:
SukkaW
2026-07-27 02:59:21 +08:00
parent 86f55a4929
commit 1b000a8cea
8 changed files with 226 additions and 168 deletions

View File

@@ -9,6 +9,10 @@ import { OUTPUT_MODULES_DIR, OUTPUT_SURGE_DIR } from '../../constants/dir';
import { withBannerArray, withIdentityContent } from '../misc';
import { MARKER_DOMAIN } from '../../constants/description';
const rChar = /([a-z])\?/g;
const rWildcard = /\*+/g;
const rPattern = /\((?:([^()|]+)\|)+([^()|]*)\)/g;
export class SurgeDomainSet extends BaseWriteStrategy {
public readonly name = 'surge domainset';
@@ -204,15 +208,15 @@ export class SurgeMitmSgmodule extends BaseWriteStrategy {
// pre process regex
.replaceAll(String.raw`\.`, '.')
.replaceAll('.+', '*')
.replaceAll(/([a-z])\?/g, '($1|)')
.replaceAll(rChar, '($1|)')
// convert regex to surge hostlist syntax
.replaceAll('([a-z])', '?')
.replaceAll(String.raw`\d`, '?')
.replaceAll(/\*+/g, '*');
.replaceAll(rWildcard, '*');
let processed: string[] = [potentialHostname];
const matches = [...potentialHostname.matchAll(/\((?:([^()|]+)\|)+([^()|]*)\)/g)];
const matches = [...potentialHostname.matchAll(rPattern)];
if (matches.length > 0) {
const replaceVariant = (combinations: string[], fullMatch: string, options: string[]): string[] => {