Skip to content

Commit

Permalink
feat: add Arabic regex to url validation util
Browse files Browse the repository at this point in the history
  • Loading branch information
amir2mi committed Apr 24, 2023
1 parent b158399 commit cfcc2d3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export function isValidUrl(string: string) {
// Regex Source: https://www.freecodecamp.org/news/check-if-a-javascript-string-is-a-url/
const urlPattern = new RegExp(
"^(https?:\\/\\/)" + // validate protocol
"((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // validate domain name
"((([a-z\u0600-\u065F\u066E-\u06D5\\d]([a-z\u0600-\u065F\u066E-\u06D5\\d-]*[a-z\u0600-\u065F\u066E-\u06D5\\d])*)\\.)+[a-z\u0600-\u065F\u066E-\u06D5]{2,}|" + // validate domain name
"((\\d{1,3}\\.){3}\\d{1,3}))" + // validate OR ip (v4) address
"(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // validate port and path
"(\\?[;&a-z\\d%_.~+=-]*)?" + // validate query string
Expand Down

0 comments on commit cfcc2d3

Please sign in to comment.