Skip to content
This repository has been archived by the owner on Mar 10, 2022. It is now read-only.

Commit

Permalink
(PC-11714): Improve regex for url validation
Browse files Browse the repository at this point in the history
  • Loading branch information
asagot-ansa committed Nov 9, 2021
1 parent 411508e commit 78c3012
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
export const isUrlValid = val => {
/*eslint-disable-next-line no-useless-escape*/
const urlRegex = '^(https?)://[^s$.?#].[^s]*'
const urlRegex = new RegExp(/^(http|https):\/\/([A-z0-9-_]+)\.([A-z0-9-_]{2,})/)
if (val === null || val === '') {
return true
}
const isValid = val.match(urlRegex)
return isValid
return urlRegex.test(val)
}

0 comments on commit 78c3012

Please sign in to comment.