浏览代码

Fix: pound sign handling

SukkaW 7 月之前
父节点
当前提交
8ec28f6260
共有 3 个文件被更改,包括 14 次插入10 次删除
  1. 0 2
      Build/build-cdn-download-conf.ts
  2. 0 6
      Build/lib/process-line.ts
  3. 14 2
      Build/lib/rules/base.ts

+ 0 - 2
Build/build-cdn-download-conf.ts

@@ -88,8 +88,6 @@ export const buildCdnDownloadConf = task(require.main === module, __filename)(as
     steamDomainSetPromise
   ]);
 
-  console.log(JSON.stringify(cdnDomainsList, null, 2));
-
   // Move S3 domains to download domain set, since S3 files may be large
   appendArrayInPlace(downloadDomainSet, S3OSSDomains);
   appendArrayInPlace(downloadDomainSet, steamDomainSet);

+ 0 - 6
Build/lib/process-line.ts

@@ -37,12 +37,6 @@ export function processLine(line: string): string | null {
      */
   }
 
-  const otherPoundSign = trimmed.indexOf('#');
-
-  if (otherPoundSign > 0) {
-    return trimmed.slice(0, otherPoundSign).trimEnd();
-  }
-
   return trimmed;
 }
 

+ 14 - 2
Build/lib/rules/base.ts

@@ -168,7 +168,13 @@ export class FileOutput {
   }
 
   private async addFromDomainsetPromise(source: MaybePromise<AsyncIterable<string> | Iterable<string> | string[]>) {
-    for await (const line of await source) {
+    for await (let line of await source) {
+      const otherPoundSign = line.lastIndexOf('#');
+
+      if (otherPoundSign > 0) {
+        line = line.slice(0, otherPoundSign).trimEnd();
+      }
+
       if (line[0] === '.') {
         this.addDomainSuffix(line, true);
       } else {
@@ -187,7 +193,13 @@ export class FileOutput {
   }
 
   private async addFromRulesetPromise(source: MaybePromise<AsyncIterable<string> | Iterable<string> | string[]>) {
-    for await (const line of await source) {
+    for await (let line of await source) {
+      const otherPoundSign = line.lastIndexOf('#');
+
+      if (otherPoundSign > 0) {
+        line = line.slice(0, otherPoundSign).trimEnd();
+      }
+
       const splitted = line.split(',');
       const type = splitted[0];
       const value = splitted[1];