From bc3bbb5359c2016d6acc13b0a8ee5d39a4eab3c5 Mon Sep 17 00:00:00 2001 From: Jonathan Summers-Muir Date: Fri, 15 Jul 2022 11:57:22 +1000 Subject: [PATCH] Update Auth.constants.ts --- studio/components/interfaces/Auth/Auth.constants.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/studio/components/interfaces/Auth/Auth.constants.ts b/studio/components/interfaces/Auth/Auth.constants.ts index 6225f2a760e..d7bb480d4ee 100644 --- a/studio/components/interfaces/Auth/Auth.constants.ts +++ b/studio/components/interfaces/Auth/Auth.constants.ts @@ -1,6 +1,8 @@ // [Joshen] Currently using the latter regex as the former is too strict, doesn't support // localhost - if we can combine these 2 together that'll be great but my regex-foo isn't too strong +// [MildTomato] Combined everything into domainRegex for now + // Regex from: https://stackoverflow.com/a/68002755/4807782 // modified to accept numbers in the body of domain though // examples of matches: @@ -12,7 +14,8 @@ const baseDomainRegex = /^((ftp|http|https):\/\/)?(www.)?(?!.*(ftp|http|https|www.))[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+((\/)[\w#]+)*(\/\w+\?[a-zA-Z0-9_]+=\w+(&[a-zA-Z0-9_]+=\w+)*)?$/gm // [Joshen] This regex allows for localhost as well, less strict -// export const webRegex = /^(ftp|http|https):\/\/\w+(\.\w+)*(:[0-9]+)?\/?(\/[.\w]*)*$/i +// [MildTomato] no longer used +const webRegex = /^(ftp|http|https):\/\/\w+(\.\w+)*(:[0-9]+)?\/?(\/[.\w]*)*$/i // iOS deep linking scheme https://benoitpasquier.com/deep-linking-url-scheme-ios/ const appRegex = /^[a-z0-9]+([.][a-z0-9]+)*:\/(\/[-a-z0-9._~!$&'()*+,;=:@%]+)+$/i @@ -21,7 +24,6 @@ const appRegex = /^[a-z0-9]+([.][a-z0-9]+)*:\/(\/[-a-z0-9._~!$&'()*+,;=:@%]+)+$/ const localhostRegex = /^(?:^|\s)((https?:\/\/)?(?:localhost|[\w-]+(?:\.[\w-]+)+)(:\d+)?(\/\S*)?)/i // combine the above regexes -// export const domainRegex = new RegExp(`(${webRegex.source})|(${appRegex.source})`, 'i') export const domainRegex = new RegExp( `(${baseDomainRegex.source})|(${localhostRegex.source})|(${appRegex.source})`, 'i'