Skip to content

Commit

Permalink
Improves validation RegEx
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszlenart committed Jun 14, 2016
1 parent 7621c2b commit a0fdca1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public String getUrlRegex() {
"|((\\d|[1-9]\\d|1\\d{2}|2[0-4][0-9]|25[0-5])\\.){3}" +
"(\\d|[1-9]\\d|1\\d{2}|2[0-4][0-9]|25[0-5])" +
")(:\\d+)?" +
")(((\\/+([a-z0-9$_\\.\\+!\\*\\'\\(\\),;:@&=-]|%[0-9a-f]{2})*)*" +
")(((\\/{0,1}([a-z0-9$_\\.\\+!\\*\\'\\(\\),;:@&=-]|%[0-9a-f]{2})*)*" +
"(\\?([a-z0-9$_\\.\\+!\\*\\'\\(\\),;:@&=-]|%[0-9a-f]{2})*)" +
"?)?)?" +
"(#([a-z0-9$_\\.\\+!\\*\\'\\(\\),;:@&=-]|%[0-9a-f]{2})*)?" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public void testValidUrlWithDefaultRegex() throws Exception {
assertFalse(pattern.matcher("").matches());
assertFalse(pattern.matcher(" ").matches());
assertFalse(pattern.matcher("no url").matches());
assertFalse(pattern.matcher("http://example.com////////////////////////////////////////////////////////////////////////////////////??").matches());

assertTrue(pattern.matcher("http://www.opensymphony.com").matches());
assertTrue(pattern.matcher("https://www.opensymphony.com").matches());
Expand Down

0 comments on commit a0fdca1

Please sign in to comment.