From a9c82710a6f33b636a84cc42e4d0b1964d7c1483 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Mon, 16 Oct 2017 12:36:06 +0300 Subject: [PATCH] Regression: `base_url_absolute` always has the port number (#1690) --- CHANGELOG.md | 2 +- system/src/Grav/Common/Uri.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a47789e07..766258d3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## mm/dd/2017 1. [](#bugfix) - + * Regression: `base_url_absolute` always has the port number (#1690) # v1.3.6 ## 10/12/2017 diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php index 06cf8bc87..6b82b4a46 100644 --- a/system/src/Grav/Common/Uri.php +++ b/system/src/Grav/Common/Uri.php @@ -79,6 +79,9 @@ class Uri // Build port. $this->port = isset($env['SERVER_PORT']) ? (int)$env['SERVER_PORT'] : null; + if ($this->hasStandardPort()) { + $this->port = null; + } // Build path. $request_uri = isset($env['REQUEST_URI']) ? $env['REQUEST_URI'] : ''; @@ -107,6 +110,16 @@ class Uri $this->reset(); } + /** + * Does this Uri use a standard port? + * + * @return bool + */ + protected function hasStandardPort() + { + return ($this->scheme === 'http' && $this->port === 80) || ($this->scheme === 'https' && $this->port === 443); + } + /** * @param string $url */