Skip to content

Commit 8117d9a

Browse files
enumagdg
authored andcommitted
Route: fixed PHP warning "strpos(): Offset not contained in string" (#154)
1 parent d1b379c commit 8117d9a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Application/Routers/Route.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ public function constructUrl(Application\Request $appRequest, Nette\Http\Url $re
392392
}
393393
} while (TRUE);
394394

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

396397
if ($this->type === self::HOST) {
397398
$host = $refUrl->getHost();
@@ -403,18 +404,17 @@ public function constructUrl(Application\Request $appRequest, Nette\Http\Url $re
403404
'%sld%' => isset($parts[1]) ? $parts[1] : '',
404405
'%host%' => $host,
405406
]);
406-
$url = ($this->scheme ?: $refUrl->getScheme()) . ':' . $url;
407+
$url = $scheme . ':' . $url;
407408
} else {
408409
if ($this->lastRefUrl !== $refUrl) {
409-
$scheme = ($this->scheme ?: $refUrl->getScheme());
410410
$basePath = ($this->type === self::RELATIVE ? $refUrl->getBasePath() : '');
411411
$this->lastBaseUrl = $scheme . '://' . $refUrl->getAuthority() . $basePath;
412412
$this->lastRefUrl = $refUrl;
413413
}
414414
$url = $this->lastBaseUrl . $url;
415415
}
416416

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

0 commit comments

Comments
 (0)