« get me outta code hell

data-checks: reportContentTextErrors: report invalid external URLs - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-03-01 08:13:59 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-03-31 19:19:33 -0300
commit49240a57e063844387831336908111c0229f5ec0 (patch)
tree3acb47983de83cce568de166fd8b774a07b330a2 /src
parentb37c0fd26b25a7506731a24f53bd7ae316cc5ea6 (diff)
data-checks: reportContentTextErrors: report invalid external URLs
Diffstat (limited to 'src')
-rw-r--r--src/data/checks.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/data/checks.js b/src/data/checks.js
index 79a8d4c9..d42146d4 100644
--- a/src/data/checks.js
+++ b/src/data/checks.js
@@ -574,6 +574,16 @@ export function reportContentTextErrors(wikiData, {
             continue;
           }
         }
+      } else if (node.type === 'external-link') {
+        try {
+          new URL(node.data.href);
+        } catch (error) {
+          yield {
+            index, length,
+            message:
+              `Invalid URL ${colors.red(`"${node.data.href}"`)}`,
+          };
+        }
       }
     }
   }