diff options
Diffstat (limited to 'apps/settings/src/utils/validate.js')
-rw-r--r-- | apps/settings/src/utils/validate.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/apps/settings/src/utils/validate.js b/apps/settings/src/utils/validate.js index 83af1d94fbb..7d0cf1d9e33 100644 --- a/apps/settings/src/utils/validate.js +++ b/apps/settings/src/utils/validate.js @@ -26,7 +26,7 @@ * TODO add nice validation errors for Profile page settings modal */ -import { VALIDATE_EMAIL_REGEX } from '../constants/AccountPropertyConstants' +import { VALIDATE_EMAIL_REGEX } from '../constants/AccountPropertyConstants.js' /** * Validate the email input @@ -47,6 +47,22 @@ export function validateEmail(input) { } /** + * Validate the URL input + * + * @param {string} input the input + * @return {boolean} + */ +export function validateUrl(input) { + try { + // eslint-disable-next-line no-new + new URL(input) + return true + } catch (e) { + return false + } +} + +/** * Validate the language input * * @param {object} input the input |