File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ final class Uri implements UriInterface
46
46
public function __construct ($ uri )
47
47
{
48
48
$ parts = \parse_url ($ uri );
49
- if ($ parts === false || (isset ($ parts ['scheme ' ]) && !\preg_match ('#^[a-z]+$#i ' , $ parts ['scheme ' ])) || (isset ($ parts ['host ' ]) && \preg_match ('#[\s_ %+]# ' , $ parts ['host ' ]))) {
49
+ if ($ parts === false || (isset ($ parts ['scheme ' ]) && !\preg_match ('#^[a-z]+$#i ' , $ parts ['scheme ' ])) || (isset ($ parts ['host ' ]) && \preg_match ('#[\s %+]# ' , $ parts ['host ' ]))) {
50
50
throw new \InvalidArgumentException ('Invalid URI given ' );
51
51
}
52
52
@@ -164,7 +164,7 @@ public function withHost($host)
164
164
return $ this ;
165
165
}
166
166
167
- if (\preg_match ('#[\s_ %+]# ' , $ host ) || ($ host !== '' && \parse_url ('http:// ' . $ host , \PHP_URL_HOST ) !== $ host )) {
167
+ if (\preg_match ('#[\s %+]# ' , $ host ) || ($ host !== '' && \parse_url ('http:// ' . $ host , \PHP_URL_HOST ) !== $ host )) {
168
168
throw new \InvalidArgumentException ('Invalid URI host given ' );
169
169
}
170
170
Original file line number Diff line number Diff line change @@ -120,6 +120,9 @@ public static function provideValidUris()
120
120
yield [
121
121
'http://user%20name:pass%20word@localhost/path%20name?query%20name#frag%20ment '
122
122
];
123
+ yield [
124
+ 'http://docker_container/ '
125
+ ];
123
126
}
124
127
125
128
/**
@@ -329,6 +332,16 @@ public function testWithHostReturnsNewInstanceWhenHostIsChanged()
329
332
$ this ->assertEquals ('localhost ' , $ uri ->getHost ());
330
333
}
331
334
335
+ public function testWithHostReturnsNewInstanceWhenHostIsChangedWithUnderscore ()
336
+ {
337
+ $ uri = new Uri ('http://localhost ' );
338
+
339
+ $ new = $ uri ->withHost ('docker_container ' );
340
+ $ this ->assertNotSame ($ uri , $ new );
341
+ $ this ->assertEquals ('docker_container ' , $ new ->getHost ());
342
+ $ this ->assertEquals ('localhost ' , $ uri ->getHost ());
343
+ }
344
+
332
345
public function testWithHostReturnsNewInstanceWithHostToLowerCaseWhenHostIsChangedWithUpperCase ()
333
346
{
334
347
$ uri = new Uri ('http://localhost ' );
You can’t perform that action at this time.
0 commit comments