diff --git a/Build/build-common.ts b/Build/build-common.ts index b606447e..a76fcc96 100644 --- a/Build/build-common.ts +++ b/Build/build-common.ts @@ -104,7 +104,7 @@ async function transform(parentSpan: Span, sourcePath: string, relativePath: str return parentSpan .traceChild(`transform ruleset: ${id}`) .traceAsyncFn(async (span) => { - const type = relativePath.split(path.sep)[0]; + const type = relativePath.slice(0, relativePath.indexOf(path.sep)); if (type !== 'ip' && type !== 'non_ip' && type !== 'domainset') { throw new TypeError(`Invalid type: ${type}`); diff --git a/Build/lib/writing-strategy/surge.ts b/Build/lib/writing-strategy/surge.ts index 3507c51f..6eb652db 100644 --- a/Build/lib/writing-strategy/surge.ts +++ b/Build/lib/writing-strategy/surge.ts @@ -194,7 +194,7 @@ export class SurgeMitmSgmodule extends BaseWriteStrategy { urlRegex = urlRegex.slice(9); } - const potentialHostname = urlRegex.split('/')[0] + const potentialHostname = urlRegex.slice(0, urlRegex.indexOf('/')) // pre process regex .replaceAll(String.raw`\.`, '.') .replaceAll('.+', '*')