Skip to content

Commit cf5beb9

Browse files
committed
Merge pull request #138 from dman-coders/url-parsing
More complete support of URL parsing
2 parents 6e6c07b + 0e8bcf7 commit cf5beb9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Url.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,20 @@ protected function buildUrl()
415415
$url .= $this->info['scheme'].'://';
416416
}
417417

418+
$user = isset($this->info['user']) ? $this->info['user'] : '';
419+
$pass = isset($this->info['pass']) ? ':' . $this->info['pass'] : '';
420+
if ($user || $pass) {
421+
$url .= $user . $pass . '@';
422+
}
423+
418424
if (isset($this->info['host'])) {
419425
$url .= $this->info['host'];
420426
}
421427

428+
if (isset($this->info['port'])) {
429+
$url .= ':' . $this->info['port'];
430+
}
431+
422432
$url .= $this->getPath();
423433

424434
if (!empty($this->info['query'])) {

tests/UrlTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public function urlsParserProvider()
1515
['https://animoto.com/oembeds/create.xml?automated=true&options=start_hq', 'https://animoto.com/oembeds/create.xml?automated=true&options=start_hq'],
1616
['http://static2.politico.com/dims4/default/28fb355/2147483647/resize/1160x%3E/quality/90/?url=http%3A%2F%2Fs3-origin-images.politico.com%2F2013%2F12%2F18%2F131218_george_w_bush_barack_obama_ap_60', 'http://static2.politico.com/dims4/default/28fb355/2147483647/resize/1160x%3E/quality/90/?url=http%3A%2F%2Fs3-origin-images.politico.com%2F2013%2F12%2F18%2F131218_george_w_bush_barack_obama_ap_60'],
1717
['https://plus.google.com/+carlsenverlag/posts/2hibgWrmhp1', 'https://plus.google.com/+carlsenverlag/posts/2hibgWrmhp1'],
18+
['http://test.drupal.dd:8083/tests/localport.html', 'http://test.drupal.dd:8083/tests/localport.html'],
19+
['http://[email protected]:8083/tests/identified.html', 'http://[email protected]:8083/tests/identified.html'],
20+
['http://testuser:[email protected]:8083/tests/authenticated.html', 'http://testuser:[email protected]:8083/tests/authenticated.html'],
1821
];
1922
}
2023

0 commit comments

Comments
 (0)