From 22250b483fb799d2ea7dbeaf3002a9499832fe0e Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Thu, 2 Feb 2023 14:21:53 -0500 Subject: [PATCH] Update so that requests containing a double slash at the end of the path get redirected to the single slash (or no-slash) version --- wire/core/PagesRequest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wire/core/PagesRequest.php b/wire/core/PagesRequest.php index 97bbfa53..04bbdd21 100644 --- a/wire/core/PagesRequest.php +++ b/wire/core/PagesRequest.php @@ -304,8 +304,12 @@ class PagesRequest extends Wire { // determine if index.php is referenced in URL if(stripos($this->dirtyUrl, 'index.php') !== false && stripos($path, 'index.php') === false) { - // this will force pathFinder to detect a redirect condition + // force pathFinder to detect a redirect condition without index.php $path = rtrim($path, '/') . '/index.php'; + } else if(strpos($this->dirtyUrl, '//') !== false) { + // force pathFinder to detect redirect sans double slashes, /page/path// => /page/path/ + list($dirtyUrl,) = explode('?', "$this->dirtyUrl?", 2); // exclude query string + if(strpos($dirtyUrl, '//') !== false) $path = rtrim($path, '/') . '//'; } // get info about requested path