ソースを参照

Feat: ability to handle inline comment

SukkaW 7 ヶ月 前
コミット
373f862c6d

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

@@ -88,6 +88,8 @@ 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);

+ 2 - 1
Build/build-common.ts

@@ -63,6 +63,7 @@ function processFile(span: Span, sourcePath: string) {
     let sgmodulePathname: string | null = null;
 
     try {
+      let l: string | null = '';
       for await (const line of readFileByLine(sourcePath)) {
         if (line.startsWith(MAGIC_COMMAND_SKIP)) {
           return $skip;
@@ -83,7 +84,7 @@ function processFile(span: Span, sourcePath: string) {
           continue;
         }
 
-        const l = processLine(line);
+        l = processLine(line);
         if (l) {
           lines.push(l);
         }

+ 4 - 2
Build/lib/fetch-text-by-line.ts

@@ -45,9 +45,11 @@ export function fetchRemoteTextByLine(url: string, processLine = false): Promise
 
 export async function readFileIntoProcessedArray(file: string /* | FileHandle */) {
   const results = [];
+  let processed: string | null = '';
   for await (const line of readFileByLine(file)) {
-    if (processLine(line)) {
-      results.push(line);
+    processed = processLine(line);
+    if (processed) {
+      results.push(processed);
     }
   }
   return results;

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

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

+ 2 - 1
Build/lib/run-against-source-file.ts

@@ -9,8 +9,9 @@ export default async function runAgainstSourceFile(
   /** Secret keyword collection, only use for special purpose */
   keywordSet?: Set<string> | null
 ) {
+  let l: string | null = '';
   for await (const line of readFileByLine(filePath)) {
-    const l = processLine(line);
+    l = processLine(line);
     if (!l) {
       continue;
     }

+ 3 - 1
Build/tools-dedupe-src.ts

@@ -50,8 +50,10 @@ async function dedupeFile(file: string, whitelist: HostnameSmolTrie) {
 
   const trie = new HostnameTrie();
 
+  let line: string | null = '';
+
   for await (const l of readFileByLine(file)) {
-    const line = processLine(l);
+    line = processLine(l);
 
     if (!line) {
       if (l.startsWith('# $ skip_dedupe_src')) {

+ 3 - 5
Source/domainset/cdn.conf

@@ -3217,8 +3217,7 @@ s-cdnstatic.svc.litv.tv
 jsmodule.svc.litv.tv
 bulletin.svc.litv.tv
 static.svc.litv.tv
-# Amazon S3
-fino.svc.litv.tv
+fino.svc.litv.tv # Amazon S3
 player.svc.litv.tv
 
 # >> General CDN
@@ -4804,9 +4803,6 @@ images.findagrave.com
 cdn.streamlabs.com
 sp.streamlabs.com
 images.blockscan.com
-# AWS S3
-cdn.highporn.net
-img.highporn.net
 apim.m3pd.com
 eomd1.fembeqq.xyz
 .anyhentai.com
@@ -4844,3 +4840,5 @@ cms.worldpokerdeals.com
 assets.hackmd.io
 images.mooncloud.top
 pmecdn.protonweb.com
+cdn.highporn.net # AWS S3
+img.highporn.net