Validate localhost url
See original GitHub issueCould you please provide a way to allow localhost as a valid url string? Something like validate.js’s allowLocal
flag: https://validatejs.org/#validators-url:
let validationSchema = Yup.object().shape({
url: Yup.string().url('Please enter a valid URL, including scheme', { allowLocal: true })
});
Thanks.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:16
- Comments:10 (1 by maintainers)
Top Results From Across the Web
UrlValidator is not working for localhost - Stack Overflow
I'm facing an issue that i'm using UrlValidator in my code. UrlValidator urlValidator = UrlValidator.getInstance(); if(urlValidator.isValid(url)) ...
Read more >Check if a URL is localhost in JavaScript | bobbyhadz
Use the includes() method to check if a URL is localhost . The includes method will return true if the URL is localhost,...
Read more >URL (with localhost) - Regex Tester/Debugger
Test String. http://localhost ... Url Validation Regex | Regular Expression - Taha · date format (yyyy-mm-dd) · Match an email address
Read more >3421 (URLField does not validate IP addresses, or localhost)
In [47]: f.clean('http://localhost') ... ValidationError: [u'Enter a valid URL.'] In [48]: f.clean('http:// ...
Read more >Check if an URL is valid or not using Regular Expression
The URL must start with either http or https and · then it must contain www. and · then followed by subdomain of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jquense I’m having the same problem trying to use
yup.string().url()
to validate an URL starting with “http://localhost:3000/”. I’ve seen that this issue was closed but I’m interested in fixing the problem. Would you still accept a PR for a regex that supports that kind of URL?I don’t have time right this second to make and test the modification and submit a PR, though I might in the next few days. In case I don’t get to it, here’s a regex you can use to replace the one
rUrl
one you’re already using instring.js
:I tested it here: https://www.regexpal.com/?fam=104762
It’s derived from https://gist.github.com/dperini/729294 with a few modifications:
dperini’s regex is pretty widely regarded as the best one for matching URLs. The alternative is to use a real URL parsing lib instead of a regex, which is probably a good idea, but will increase the size of this lib.