From 137cbbd1867b2df389fa2428557c6ae67b4e51a0 Mon Sep 17 00:00:00 2001 From: adrianbj Date: Fri, 23 Dec 2016 08:38:20 -0800 Subject: [PATCH] Fix for incorrect path returned from $input->url() when called before page is available. It used to return: //admin/page/edit/-id-1111/?id=1111 Instead of the correct: /admin/page/edit/?id=1111 This appears to fix everything correctly. --- wire/core/WireInput.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/wire/core/WireInput.php b/wire/core/WireInput.php index 63e0bd48..5a92bd61 100644 --- a/wire/core/WireInput.php +++ b/wire/core/WireInput.php @@ -489,12 +489,15 @@ class WireInput extends Wire { } else if(isset($_SERVER['REQUEST_URI'])) { // page not yet available, attempt to pull URL from request uri - $parts = explode('/', $_SERVER['REQUEST_URI']); - $charset = $config->pageNameCharset; - foreach($parts as $part) { - $url .= "/" . ($charset === 'UTF8' ? $sanitizer->pageNameUTF8($part) : $sanitizer->pageName($part, false)); - } $info = parse_url($_SERVER['REQUEST_URI']); + $parts = explode('/', $info['path']); + $charset = $config->pageNameCharset; + $i = 0; + foreach($parts as $part) { + if($i > 0) $url .= "/"; + $url .= ($charset === 'UTF8' ? $sanitizer->pageNameUTF8($part) : $sanitizer->pageName($part, false)); + $i++; + } if(!empty($info['path']) && substr($info['path'], -1) == '/') { $url = rtrim($url, '/') . '/'; // trailing slash }