]> git.ipfire.org Git - thirdparty/blocklistproject/lists.git/commitdiff
Adding lint rule to disallow whitespace in urls 434/head
authorCharlie Fish <fishcharlie@me.com>
Fri, 30 Jul 2021 04:03:21 +0000 (22:03 -0600)
committerCharlie Fish <fishcharlie@me.com>
Fri, 30 Jul 2021 04:03:21 +0000 (22:03 -0600)
scripts/lint.js

index b72d2191e5f65a50255e6ec889048f118e1c6319..91b18556d59865901a795983b8690850f0f63e2e 100644 (file)
@@ -59,6 +59,16 @@ const path = require("path");
                                        hasError = true;
                                }
                        }
+
+                       // Ensure that the URL doesn't contain whitespace characters
+                       if (line.startsWith("0.0.0.0 ")) {
+                               const lineNoIP = line.replace("0.0.0.0 ", "");
+                               const url = lineNoIP.split("#")[0].trim();
+                               if (/\s/gmu.test(url)) {
+                                       console.error(`Line ${index + 1} in ${file} url ${url} contains whitespace in the URL.`);
+                                       hasError = true;
+                               }
+                       }
                });
        }));