Skip to content

Commit 701517d

Browse files
committed
修复特定场景下的重定向 Uri 处理
1 parent aba10dc commit 701517d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/YurunHttp/Traits/THandler.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ public function parseRedirectLocation($location, $currentUri)
3131
}
3232
else
3333
{
34-
$path = \dirname($currentUri);
35-
if ('\\' === \DIRECTORY_SEPARATOR && false !== strpos($path, \DIRECTORY_SEPARATOR))
34+
$uri = $currentUri;
35+
$path = $currentUri->getPath();
36+
if('/' !== substr($path, -1, 1))
3637
{
37-
$path = str_replace(\DIRECTORY_SEPARATOR, '/', $path);
38+
$path = $path . '/';
3839
}
39-
$uri = new Uri($path . '/' . $location);
40+
$path .= $location;
41+
$uri = $uri->withPath($path);
4042
}
43+
$uri = $uri->withHost($currentUri->getHost())->withPort($currentUri->getPort());
4144
}
4245
else
4346
{

0 commit comments

Comments
 (0)