Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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})'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any link/resource to verify the validity of this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Loopback IP address ranges from 127.0.0.0 to 127.255.255.255 and as per the Issue the Loopback address(es) should be valid for testing purposes so I removed the 127 address from the exclusion list as it was just excluding any addresses beginning with 10/127.

+ '(?!(?: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