Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit df8828e

Browse files
mtagliabmichalbundyra
authored andcommitted
Remove ending colon from URI without port
1 parent 81af14a commit df8828e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Uri.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,16 @@ public function parse($uri)
301301
$this->setUserInfo($userInfo);
302302
}
303303

304-
$nMatches = preg_match('/:[\d]{1,5}$/', $authority, $matches);
304+
$nMatches = preg_match('/:[\d]{0,5}$/', $authority, $matches);
305305
if ($nMatches === 1) {
306306
$portLength = strlen($matches[0]);
307307
$port = substr($matches[0], 1);
308+
309+
// If authority ends with colon, port will be empty string.
310+
// Remove the colon from authority, but keeps port null
311+
if($port !== ''){
312+
$this->setPort((int) $port);
313+
}
308314

309315
$this->setPort((int) $port);
310316
$authority = substr($authority, 0, -$portLength);

0 commit comments

Comments
 (0)