Fix whitespace only urls

This commit is contained in:
shamoon
2026-09-24 16:47:17 -07:00
parent 9cbd0b2e24
commit 3c21057f41
2 changed files with 5 additions and 2 deletions
+3 -2
View File
@@ -11,9 +11,10 @@ function getText(node) {
}
export function httpUrl(value, baseUrl) {
if (!value) return null;
const trimmed = value?.trim();
if (!trimmed) return null;
try {
const url = new URL(value.trim(), baseUrl);
const url = new URL(trimmed, baseUrl);
return ["http:", "https:"].includes(url.protocol) ? url.href : null;
} catch {
return null;