Skip to content

Commit

Permalink
Added check for ports
Browse files Browse the repository at this point in the history
On some urls there is a port specified after the suffix. An extra check
has been added to test for those cases as well.
  • Loading branch information
flacle committed Dec 22, 2015
1 parent fb8f728 commit 5ee2ed9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
'xn--85x722f.com.cn',
'www.食狮.公司.cn',
'http://username:[email protected]/',
'http://username:[email protected]:9090/path?arg=value#anchor',
'mailto:[email protected]',
'mailto:[email protected]?subject=This%20is%20the%20subject'. //cont...
'&[email protected]&body=This%20is%20the%20body',
Expand Down
6 changes: 6 additions & 0 deletions src/parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ function cleanseURL(&$url) {
$url = substr($url, 0, $queries);
}

// Check for remaining ports and remove them
$ports = strrpos($url, ':');
if ($ports !== false) {
$url = substr($url, 0, $ports);
}

// Append a random char such as % at the end for faster TLD matching
$url = $url.'%';
}
Expand Down

0 comments on commit 5ee2ed9

Please sign in to comment.