fix web review validation and clipboard tests

This commit is contained in:
2026-07-19 20:50:42 +08:00
parent ec59dee6b9
commit 884148b88f
5 changed files with 69 additions and 3 deletions

View File

@@ -13,7 +13,7 @@
return { error: 'Enter a server address.' };
}
if (hasWhitespace(value) || hasUnsupportedProtocol(value)) {
if (hasWhitespace(value) || value.includes('\\') || hasMalformedHttpProtocol(value) || hasUnsupportedProtocol(value)) {
return { error: 'Enter a valid HTTP or HTTPS server address.' };
}
@@ -58,6 +58,10 @@
return /^[a-z][a-z\d+.-]*:(?!\d)/i.test(value);
}
function hasMalformedHttpProtocol(value: string): boolean {
return /^https?:\/(?!\/)/i.test(value) || /^https?\/{2}(?!\/)/i.test(value);
}
function hasCredentials(value: string): boolean {
const authority = value.replace(/^https?:\/\//i, '').split(/[/?#]/, 1)[0];
return authority.includes('@');