dperini updated the gist
old code
"(?!10(?:\\.\\d{1,3}){3})" + "(?!127(?:\\.\\d{1,3}){3})" + "(?!169\\.254(?:\\.\\d{1,3}){2})" + "(?!192\\.168(?:\\.\\d{1,3}){2})" + ... // path "(?:\\/[^\\s]*)?" +
new code
"(?!(?:10|127)(?:\\.\\d{1,3}){3})" + "(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})" + ... // resource path "(?:[/?#]\\S*)?" +
major change is that http://example.com?query and http://example.com#query used to be detected as invalid (that's bad), while the new regex allows them
http://example.com?query
http://example.com#query
The text was updated successfully, but these errors were encountered:
Can you show a case where the existing validate.js code doesn't work?
Both queries and fragments work: https://github.com/ansman/validate.js/blob/master/specs/validators/url-spec.js#L73
Sorry, something went wrong.
http://example.com/path?query works, but http://example.com?query doesn't. dperini's updated gist fixes that
http://example.com/path?query
cffa61a
Got it, thanks.
Oh wait, I realized that's not all.
Hostname match is now
(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)
instead of
(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)
which solves the catastrophic backtracking problem by removing the +, and also supports http://g--a.com
+
http://g--a.com
It would be wise to update the entire regex in order to get all the fixes
Done
Released in 0.11.0
No branches or pull requests
dperini updated the gist
old code
new code
major change is that
http://example.com?query
andhttp://example.com#query
used to be detected as invalid (that's bad), while the new regex allows themThe text was updated successfully, but these errors were encountered: