mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Feat: Surge DOMAIN-WILDCARD -> Clash DOMAIN-REGEX
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { dirname } from 'path';
|
||||
import fs from 'fs';
|
||||
import fsp from 'fs/promises';
|
||||
import { makeRe } from 'picomatch';
|
||||
|
||||
export const isTruthy = <T>(i: T | 0 | '' | false | null | undefined): i is T => !!i;
|
||||
|
||||
@@ -28,3 +29,7 @@ export const writeFile: Write = async (destination: string, input, dir = dirname
|
||||
}
|
||||
return fsp.writeFile(destination, input, { encoding: 'utf-8' });
|
||||
};
|
||||
|
||||
export const domainWildCardToRegex = (domain: string) => {
|
||||
return makeRe(domain, { contains: false, strictSlashes: true }).source;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user