]> git.ipfire.org Git - thirdparty/blocklistproject/lists.git/commitdiff
Checking to ensure all URLs are lowercase in linter
authorCharlie Fish <fishcharlie@me.com>
Sun, 4 Jul 2021 17:56:23 +0000 (11:56 -0600)
committerCharlie Fish <fishcharlie@me.com>
Sun, 4 Jul 2021 17:56:23 +0000 (11:56 -0600)
scripts/lint.js

index 0f853ab4f0a82b741ddc7aafb930a92b11c633a2..f7d8ff665f55596a603622b81c3d47070ab721a9 100644 (file)
@@ -9,10 +9,21 @@ const path = require("path");
                const fileContents = await fs.readFile(path.join(__dirname, "..", file), "utf8"); // Get file contents as a string
 
                fileContents.split("\n").forEach((line, index) => {
+                       // Ensuring that all lines start with "#" or "0.0.0.0 "
                        if (line.length > 0 && !line.startsWith("#") && !line.startsWith("0.0.0.0 ")) {
                                console.error(`Line ${index + 1} in ${file} must start with "#" or "0.0.0.0 ".`);
                                hasError = true;
                        }
+
+                       // Checking to ensure all URLs are lowercase
+                       if (line.startsWith("0.0.0.0 ")) {
+                               const lineNoIP = line.replace("0.0.0.0 ", "");
+                               const url = lineNoIP.split("#")[0].trim();
+                               if (url.toLowerCase() !== url) {
+                                       console.error(`Line ${index + 1} in ${file} url ${url} must be all lowercase.`);
+                                       hasError = true;
+                               }
+                       }
                });
        }));