Skip to content

Commit d19c235

Browse files
committed
fix: spark routes shows incorrect hostname routes
1 parent c58889b commit d19c235

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

system/Router/RouteCollection.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,13 +1316,12 @@ protected function create(string $verb, string $from, $to, ?array $options = nul
13161316
// Hostname limiting?
13171317
if (! empty($options['hostname'])) {
13181318
// @todo determine if there's a way to whitelist hosts?
1319-
if (isset($this->httpHost) && strtolower($this->httpHost) !== strtolower($options['hostname'])) {
1319+
if (! $this->checkHostname($options['hostname'])) {
13201320
return;
13211321
}
13221322

13231323
$overwrite = true;
13241324
}
1325-
13261325
// Limiting to subdomains?
13271326
elseif (! empty($options['subdomain'])) {
13281327
// If we don't match the current subdomain, then
@@ -1395,6 +1394,22 @@ protected function create(string $verb, string $from, $to, ?array $options = nul
13951394
}
13961395
}
13971396

1397+
/**
1398+
* Compares the hostname passed in against the current hostname
1399+
* on this page request.
1400+
*
1401+
* @param string $hostname Hostname in route options
1402+
*/
1403+
private function checkHostname($hostname): bool
1404+
{
1405+
// CLI calls can't be on hostname.
1406+
if (! isset($this->httpHost)) {
1407+
return false;
1408+
}
1409+
1410+
return strtolower($this->httpHost) === strtolower($hostname);
1411+
}
1412+
13981413
private function processArrayCallableSyntax(string $from, array $to): string
13991414
{
14001415
// [classname, method]

0 commit comments

Comments
 (0)