Skip to content

Commit

Permalink
Route: fixed PHP warning "strpos(): Offset not contained in string" (n…
Browse files Browse the repository at this point in the history
  • Loading branch information
enumag authored and dg committed Feb 3, 2019
1 parent 827ad7c commit 8325d6f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Routing/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ public function constructUrl(Application\Request $appRequest, Nette\Http\Url $re
}
} while (TRUE);

$scheme = $this->scheme ?: $refUrl->getScheme();

if ($this->type === self::HOST) {
$host = $refUrl->getHost();
Expand All @@ -400,18 +401,17 @@ public function constructUrl(Application\Request $appRequest, Nette\Http\Url $re
'%sld%' => isset($parts[1]) ? $parts[1] : '',
'%host%' => $host,
]);
$url = ($this->scheme ?: $refUrl->getScheme()) . ':' . $url;
$url = $scheme . ':' . $url;
} else {
if ($this->lastRefUrl !== $refUrl) {
$scheme = ($this->scheme ?: $refUrl->getScheme());
$basePath = ($this->type === self::RELATIVE ? $refUrl->getBasePath() : '');
$this->lastBaseUrl = $scheme . '://' . $refUrl->getAuthority() . $basePath;
$this->lastRefUrl = $refUrl;
}
$url = $this->lastBaseUrl . $url;
}

if (strpos($url, '//', 7) !== FALSE) {
if (strpos($url, '//', strlen($scheme) + 3) !== FALSE) {
return NULL;
}

Expand Down

0 comments on commit 8325d6f

Please sign in to comment.