Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: standardise the usage of url validator #17564

Merged
merged 9 commits into from
Apr 26, 2023
2 changes: 0 additions & 2 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -917,8 +917,6 @@ const CONST = {
PAYPAL_ME_USERNAME: /^[a-zA-Z0-9]+$/,
ROOM_NAME: /^#[a-z0-9-]{1,80}$/,

WEBSITE: /^((https?|ftp):\/\/)(([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}(:\d+)?(\/[-a-z\d%_.~+]*)*(\?[;&a-z\d%_.~+=-]*)?(#[-a-z\d_]*)?$/i,

// eslint-disable-next-line max-len, no-misleading-character-class
EMOJIS: /[\p{Extended_Pictographic}\u200d\u{1f1e6}-\u{1f1ff}\u{1f3fb}-\u{1f3ff}\u{e0020}-\u{e007f}\u20E3\uFE0F]|[#*0-9]\uFE0F?\u20E3/gu,
TAX_ID: /^\d{9}$/,
Expand Down
3 changes: 2 additions & 1 deletion src/libs/ValidationUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import moment from 'moment';
import _ from 'underscore';
import {URL_REGEX_WITH_REQUIRED_PROTOCOL} from 'expensify-common/lib/Url';
import CONST from '../CONST';
import * as CardUtils from './CardUtils';
import * as LoginUtils from './LoginUtils';
Expand Down Expand Up @@ -238,7 +239,7 @@ function getAgeRequirementError(date, minimumAge, maximumAge) {
* @returns {Boolean}
*/
function isValidWebsite(url) {
return CONST.REGEX.WEBSITE.test(url);
return new RegExp(`^${URL_REGEX_WITH_REQUIRED_PROTOCOL}$`, 'i').test(url);
}

/**
Expand Down