fix web review validation and clipboard tests
This commit is contained in:
@@ -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('@');
|
||||
|
||||
Reference in New Issue
Block a user