mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 17:20:35 +08:00
Refactor: minor changes
This commit is contained in:
parent
098e8815ae
commit
b4df4bab00
@ -28,9 +28,7 @@ export const buildCommon = task(import.meta.main, import.meta.path)(async (span)
|
||||
// if (dirName === 'domainset' || dirName === 'ip' || dirName === 'non_ip') {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// console.error(picocolors.red(`[build-comman] Unknown dir: ${dirPath}`));
|
||||
|
||||
// console.error(picocolors.red(`[build-comman] Unknown dir: ${dirPath}`));
|
||||
// return true;
|
||||
// })
|
||||
.filter((filepath, isDirectory) => {
|
||||
|
||||
@ -44,7 +44,7 @@ const HOSTNAMES = [
|
||||
|
||||
export const buildAlwaysRealIPModule = task(import.meta.main, import.meta.path)(async (span) => {
|
||||
// Intranet, Router Setup, and mant more
|
||||
const dataset = ([Object.entries(DIRECTS), Object.entries(LANS)]);
|
||||
const dataset = [Object.entries(DIRECTS), Object.entries(LANS)];
|
||||
const surge = dataset.flatMap(data => data.flatMap(([, { domains }]) => domains.flatMap((domain) => [`*.${domain}`, domain])));
|
||||
const clash = dataset.flatMap(data => data.flatMap(([, { domains }]) => domains.map((domain) => `+.${domain}`)));
|
||||
|
||||
|
||||
@ -434,28 +434,41 @@ function parse($line: string, gorhill: PublicSuffixList, result: [string, ParseT
|
||||
let sliceStart = 0;
|
||||
let sliceEnd: number | undefined;
|
||||
|
||||
if (line[2] === '|') { // line.startsWith('@@|')
|
||||
sliceStart = 3;
|
||||
whiteIncludeAllSubDomain = false;
|
||||
switch (line[2]) {
|
||||
case '|':
|
||||
// line.startsWith('@@|')
|
||||
sliceStart = 3;
|
||||
whiteIncludeAllSubDomain = false;
|
||||
|
||||
if (line[3] === '|') { // line.startsWith('@@||')
|
||||
sliceStart = 4;
|
||||
if (line[3] === '|') { // line.startsWith('@@||')
|
||||
sliceStart = 4;
|
||||
whiteIncludeAllSubDomain = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case '.': { // line.startsWith('@@.')
|
||||
sliceStart = 3;
|
||||
whiteIncludeAllSubDomain = true;
|
||||
break;
|
||||
}
|
||||
} else if (line[2] === '.') { // line.startsWith('@@.')
|
||||
sliceStart = 3;
|
||||
whiteIncludeAllSubDomain = true;
|
||||
} else if (
|
||||
/**
|
||||
* line.startsWith('@@://')
|
||||
*
|
||||
* `@@://googleadservices.com^|`
|
||||
* `@@://www.googleadservices.com^|`
|
||||
*/
|
||||
line[2] === ':' && line[3] === '/' && line[4] === '/'
|
||||
) {
|
||||
whiteIncludeAllSubDomain = false;
|
||||
sliceStart = 5;
|
||||
|
||||
case ':': {
|
||||
/**
|
||||
* line.startsWith('@@://')
|
||||
*
|
||||
* `@@://googleadservices.com^|`
|
||||
* `@@://www.googleadservices.com^|`
|
||||
*/
|
||||
if (line[3] === '/' && line[4] === '/') {
|
||||
whiteIncludeAllSubDomain = false;
|
||||
sliceStart = 5;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (lineEndsWithCaretOrCaretVerticalBar) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user