diff --git a/Request.php b/Request.php index 75db0300b..561cb887f 100644 --- a/Request.php +++ b/Request.php @@ -355,7 +355,11 @@ public static function create(string $uri, string $method = 'GET', array $parame $server['PATH_INFO'] = ''; $server['REQUEST_METHOD'] = strtoupper($method); - $components = parse_url($uri); + if (false === ($components = parse_url($uri)) && '/' === ($uri[0] ?? '')) { + $components = parse_url($uri.'#'); + unset($components['fragment']); + } + if (isset($components['host'])) { $server['SERVER_NAME'] = $components['host']; $server['HTTP_HOST'] = $components['host']; diff --git a/Tests/RequestTest.php b/Tests/RequestTest.php index 395df09c5..082e8695c 100644 --- a/Tests/RequestTest.php +++ b/Tests/RequestTest.php @@ -244,6 +244,9 @@ public function testCreate() // Fragment should not be included in the URI $request = Request::create('http://test.com/foo#bar'); $this->assertEquals('http://test.com/foo', $request->getUri()); + + $request = Request::create('/foo:123'); + $this->assertEquals('http://localhost/foo:123', $request->getUri()); } public function testCreateWithRequestUri()