Skip to content

Commit c7fbe00

Browse files
GrotaxCopilot
andauthored
Apply suggestions from code review
Co-authored-by: Copilot <[email protected]>
1 parent 2eea4a5 commit c7fbe00

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/FeedIo/Adapter/Http/Client.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ protected function resolveRedirectUrl(string $currentUrl, string $location): str
154154
// Parse current URL
155155
$parts = parse_url($currentUrl);
156156
if (!$parts) {
157-
return $location;
157+
throw new ServerErrorException(
158+
new \Nyholm\Psr7\Response(500, [], 'Invalid URL'),
159+
0
160+
);
158161
}
159162

160163
$scheme = $parts['scheme'] ?? 'http';
@@ -174,6 +177,7 @@ protected function resolveRedirectUrl(string $currentUrl, string $location): str
174177
}
175178

176179
$port = isset($parts['port']) ? ':' . $parts['port'] : '';
177-
return "{$scheme}://{$host}{$port}{$basePath}/{$location}";
180+
$separator = str_ends_with($basePath, '/') ? '' : '/';
181+
return "{$scheme}://{$host}{$port}{$basePath}{$separator}{$location}";
178182
}
179183
}

0 commit comments

Comments
 (0)