Skip to content

Commit

Permalink
fix port on link generation
Browse files Browse the repository at this point in the history
  • Loading branch information
carloscarucce committed Feb 17, 2022
1 parent b65f50c commit 426c8be
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Mvc/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,15 @@ protected function link(string $ref, array $params = [], string $schema = null):
$schema = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http';
}

$defaultPort = ($schema == 'https') ? 443 : 80;

//Capture complete URL
$completeUrl = "$schema://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}";
$completeUrl = "$schema://{$_SERVER['SERVER_NAME']}";
if (!$_SERVER['SERVER_PORT'] != $defaultPort) {
$completeUrl .= ":{$_SERVER['SERVER_PORT']}";
}
$completeUrl .= $_SERVER['REQUEST_URI'];

$routeStr = Request::current()->getRouteStr();

//clear params from complete url
Expand Down

0 comments on commit 426c8be

Please sign in to comment.