Skip to content

Commit ce9872f

Browse files
reetamnandikushthedude
authored andcommitted
fix: RegExp for URLs (#3553)
1 parent 2f7ef70 commit ce9872f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

app/utils/validators.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ export const compulsoryProtocolValidUrlPattern = new RegExp('^(https?:\\/\\/)' /
2020

2121
export const protocolLessValidUrlPattern = new RegExp(
2222
'^'
23+
// localhost inclusion
24+
+ '(?:(?:localhost)(:\\d{2,5})?|'
2325
// user:pass authentication
2426
+ '(?:\\S+(?::\\S*)?@)?'
2527
+ '(?:'
2628
// IP address exclusion
2729
// private & local networks
28-
+ '(?!(?:10|127)(?:\\.\\d{1,3}){3})'
30+
+ '(?!(?:10)(?:\\.\\d{1,3}){3})'
2931
+ '(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})'
3032
+ '(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})'
3133
// IP address dotted notation octets
@@ -49,7 +51,7 @@ export const protocolLessValidUrlPattern = new RegExp(
4951
// port number
5052
+ '(?::\\d{2,5})?'
5153
// resource path
52-
+ '(?:[/?#]\\S*)?'
54+
+ '(?:[/?#]\\S*)?)'
5355
+ '$', 'i'
5456
);
5557

0 commit comments

Comments
 (0)