Skip to content

Commit

Permalink
fix: RegExp for URLs (#3553)
Browse files Browse the repository at this point in the history
  • Loading branch information
reetamnandi authored and kushthedude committed Oct 28, 2019
1 parent 2f7ef70 commit ce9872f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/utils/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ export const compulsoryProtocolValidUrlPattern = new RegExp('^(https?:\\/\\/)' /

export const protocolLessValidUrlPattern = new RegExp(
'^'
// localhost inclusion
+ '(?:(?:localhost)(:\\d{2,5})?|'
// user:pass authentication
+ '(?:\\S+(?::\\S*)?@)?'
+ '(?:'
// IP address exclusion
// private & local networks
+ '(?!(?:10|127)(?:\\.\\d{1,3}){3})'
+ '(?!(?:10)(?:\\.\\d{1,3}){3})'
+ '(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})'
+ '(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})'
// IP address dotted notation octets
Expand All @@ -49,7 +51,7 @@ export const protocolLessValidUrlPattern = new RegExp(
// port number
+ '(?::\\d{2,5})?'
// resource path
+ '(?:[/?#]\\S*)?'
+ '(?:[/?#]\\S*)?)'
+ '$', 'i'
);

Expand Down

0 comments on commit ce9872f

Please sign in to comment.