From: Charlie Fish Date: Sun, 4 Jul 2021 17:56:23 +0000 (-0600) Subject: Checking to ensure all URLs are lowercase in linter X-Git-Tag: aggregated-20250518~474^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb5e125291235c29f19c14d4a4705d972a3b7858;p=thirdparty%2Fblocklistproject%2Flists.git Checking to ensure all URLs are lowercase in linter --- diff --git a/scripts/lint.js b/scripts/lint.js index 0f853ab..f7d8ff6 100644 --- a/scripts/lint.js +++ b/scripts/lint.js @@ -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; + } + } }); }));