Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
Fix some with the url validator
Browse files Browse the repository at this point in the history
This closes #153
  • Loading branch information
Nicklas Ansman Giertz authored and Nicklas Ansman Giertz committed Aug 31, 2016
1 parent b0668a6 commit cffa61a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2377,6 +2377,11 @@ <h3>
<li>
Errors are now deduplicated when using the flat or grouped format.
</li>
<li>
Fixed an issue where some URLs would be detected as invalid when
they weren't. Thanks <a href="github.com/ansman/validate.js/issues/153" target="_blank">huan086</a>
for reporting this.
</li>
</ul>
</div>
<div id="changelog-0-10-0">
Expand Down
4 changes: 4 additions & 0 deletions specs/validators/url-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ describe("validators.url", function() {
});

it("allows valid urls", function() {
expect(url("http://foo.com", {})).not.toBeDefined();
expect(url("http://foo.com/", {})).not.toBeDefined();
expect(url("http://foo.com/blah_blah", {})).not.toBeDefined();
expect(url("http://foo.com/blah_blah/", {})).not.toBeDefined();
expect(url("http://foo.com/blah_blah_(wikipedia)", {})).not.toBeDefined();
expect(url("http://foo.com/blah_blah_(wikipedia)_(again)", {})).not.toBeDefined();
expect(url("http://foo.com?query=bar", {})).not.toBeDefined();
expect(url("http://foo.com#fragment=bar", {})).not.toBeDefined();
expect(url("http://www.example.com/wpstyle/?p=364", {})).not.toBeDefined();
expect(url("https://www.example.com/foo/?bar=baz&inga=42&quux", {})).not.toBeDefined();
expect(url("https://www.example.com/foo/#bar=baz&inga=42&quux", {})).not.toBeDefined();
Expand Down
2 changes: 1 addition & 1 deletion validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@
// port number
"(?::\\d{2,5})?" +
// path
"(?:\\/[^\\s]*)?" +
"(?:[/?#]\\S*)?" +
"$";

var PATTERN = new RegExp(regex, 'i');
Expand Down

0 comments on commit cffa61a

Please sign in to comment.