Fix default protocol validation list

This commit is contained in:
Gabe Kangas 2022-12-14 23:33:32 -08:00
parent 5951ce527b
commit 7d2e2537cf
No known key found for this signature in database
GPG key ID: 4345B2060657F330
2 changed files with 3 additions and 12 deletions

View file

@ -69,16 +69,7 @@ const ActionModal = (props: Props) => {
}
function canSave(): Boolean {
try {
const validationObject = new URL(actionUrl);
if (validationObject.protocol !== 'https:') {
return false;
}
} catch {
return false;
}
return isValidUrl(actionUrl) && actionTitle !== '';
return isValidUrl(actionUrl, ['https:']) && actionTitle !== '';
}
const okButtonProps = {

View file

@ -7,10 +7,10 @@ export const DEFAULT_TEXTFIELD_URL_PATTERN = 'https?://.*';
* @param {string[]} validProtocols - An array of valid protocols. Defaults to web.
* @returns {boolean} - True if the URI is valid, false otherwise.
*/
export function isValidUrl(url: string, validProtocols: string[] = ['http', 'https']): boolean {
console.log(url, validProtocols);
export function isValidUrl(url: string, validProtocols: string[] = ['http:', 'https:']): boolean {
try {
const validationObject = new URL(url);
if (
validationObject.protocol === '' ||
validationObject.hostname === '' ||