Skip to content

Commit 819f30f

Browse files
committed
Route: by default keeps the currently used HTTP/HTTPS protocol regardless to destination domain
1 parent 8127ece commit 819f30f

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

src/Application/Routers/Route.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,7 @@ public function constructUrl(Application\Request $appRequest, Nette\Http\Url $re
401401
'%domain%' => isset($parts[1]) ? "$parts[1].$parts[0]" : $parts[0],
402402
'%sld%' => isset($parts[1]) ? $parts[1] : '',
403403
]);
404-
if ($this->scheme) {
405-
$url = $this->scheme . ':' . $url;
406-
} elseif (strncmp($url, "//$host/", strlen($host) + 3) === 0) {
407-
$url = $refUrl->getScheme() . ':' . $url;
408-
} else {
409-
$url = 'http:' . $url;
410-
}
404+
$url = ($this->scheme ?: $refUrl->getScheme()) . ':' . $url;
411405
} else {
412406
if ($this->lastRefUrl !== $refUrl) {
413407
$scheme = ($this->scheme ?: $refUrl->getScheme());

tests/Routers/Route.withHost.secured.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $url = $route->constructUrl(
3030
new Request('Default', NULL, ['action' => 'default']),
3131
new Url('https://example.com')
3232
);
33-
Assert::same('http://example.org/test', $url);
33+
Assert::same('https://example.org/test', $url);
3434

3535

3636

0 commit comments

Comments
 (0)