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 @@ -55,7 +55,7 @@ public function __construct($uri)
5555 }
5656 // @codeCoverageIgnoreEnd
5757
58- if ($ parts === false || (isset ($ parts ['scheme ' ]) && !\preg_match ('#^[a-z]+$#i ' , $ parts ['scheme ' ])) || (isset ($ parts ['host ' ]) && \preg_match ('#[\s_ %+]# ' , $ parts ['host ' ]))) {
58+ if ($ parts === false || (isset ($ parts ['scheme ' ]) && !\preg_match ('#^[a-z]+$#i ' , $ parts ['scheme ' ])) || (isset ($ parts ['host ' ]) && \preg_match ('#[\s %+]# ' , $ parts ['host ' ]))) {
5959 throw new \InvalidArgumentException ('Invalid URI given ' );
6060 }
6161
@@ -173,7 +173,7 @@ public function withHost($host)
173173 return $ this ;
174174 }
175175
176- if (\preg_match ('#[\s_ %+]# ' , $ host ) || ($ host !== '' && \parse_url ('http:// ' . $ host , \PHP_URL_HOST ) !== $ host )) {
176+ if (\preg_match ('#[\s %+]# ' , $ host ) || ($ host !== '' && \parse_url ('http:// ' . $ host , \PHP_URL_HOST ) !== $ host )) {
177177 throw new \InvalidArgumentException ('Invalid URI host given ' );
178178 }
179179
Original file line number Diff line number Diff line change @@ -120,6 +120,9 @@ public static function provideValidUris()
120120 ),
121121 array (
122122 'http://user%20name:pass%20word@localhost/path%20name?query%20name#frag%20ment '
123+ ),
124+ array (
125+ 'http://docker_container/ '
123126 )
124127 );
125128 }
@@ -338,6 +341,16 @@ public function testWithHostReturnsNewInstanceWhenHostIsChanged()
338341 $ this ->assertEquals ('localhost ' , $ uri ->getHost ());
339342 }
340343
344+ public function testWithHostReturnsNewInstanceWhenHostIsChangedWithUnderscore ()
345+ {
346+ $ uri = new Uri ('http://localhost ' );
347+
348+ $ new = $ uri ->withHost ('docker_container ' );
349+ $ this ->assertNotSame ($ uri , $ new );
350+ $ this ->assertEquals ('docker_container ' , $ new ->getHost ());
351+ $ this ->assertEquals ('localhost ' , $ uri ->getHost ());
352+ }
353+
341354 public function testWithHostReturnsNewInstanceWithHostToLowerCaseWhenHostIsChangedWithUpperCase ()
342355 {
343356 $ uri = new Uri ('http://localhost ' );
You can’t perform that action at this time.
0 commit comments