-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
bugSomething isn't workingSomething isn't workingpriority: mediumMedium priority issueMedium priority issue
Description
Problem
Current isValidURL regex may not handle:
localhostlocalhost:3000- IPv6 addresses
- URLs with authentication (
user:pass@host) - Data URLs
Current Implementation
var pattern = new RegExp('^(https?:\\/\\/)?' +
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' +
'((\\d{1,3}\\.){3}\\d{1,3}))' +
'(\\:\\d+)?(\\/[-a-z\\d%_.=~+!]*)*' +
'(\\?[;&a-z\\d%_.~+=/-]*)?' +
'(\\#[-a-z\\d_]*)?$', 'i');Suggested Fix
Use the URL constructor for validation:
isValidURL: {
value: function (url) {
try {
new URL(url);
return true;
} catch {
return false;
}
}
}Test Cases That Should Pass
http://localhosthttp://localhost:3000/apihttp://[::1]:8080https://example.com
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingpriority: mediumMedium priority issueMedium priority issue