Skip to content

Commit b4b45cf

Browse files
committed
:octocat: UriUtil::parseUrl(): return port as integer
1 parent a91a558 commit b4b45cf

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

src/UriUtil.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,13 @@ public static function parseUrl(string $url):array|null{
173173
return null;
174174
}
175175

176-
return array_map('urldecode', $result);
176+
$parsed = array_map('urldecode', $result);
177+
178+
if(isset($parsed['port'])){
179+
$parsed['port'] = (int)$parsed['port'];
180+
}
181+
182+
return $parsed;
177183
}
178184

179185
}

tests/UriUtilTest.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,20 @@ public static function parseUrlProvider():array{
134134
return [
135135
['http://', null],
136136
[
137-
'https://яндекAс.рф', [
138-
'scheme' => 'https',
139-
'host' => 'яндекAс.рф',
140-
],
137+
'https://яндекAс.рф',
138+
[
139+
'scheme' => 'https',
140+
'host' => 'яндекAс.рф',
141+
],
141142
],
142143
[
143-
'http://[2a00:f48:1008::212:183:10]:56?foo=bar', [
144-
'scheme' => 'http',
145-
'host' => '[2a00:f48:1008::212:183:10]',
146-
'port' => '56',
147-
'query' => 'foo=bar',
148-
],
144+
'http://[2a00:f48:1008::212:183:10]:56?foo=bar',
145+
[
146+
'scheme' => 'http',
147+
'host' => '[2a00:f48:1008::212:183:10]',
148+
'port' => 56,
149+
'query' => 'foo=bar',
150+
],
149151
],
150152
];
151153
}

0 commit comments

Comments
 (0)