1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 00:06:55 +02:00

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.
This commit is contained in:
adrianbj
2016-12-23 08:38:20 -08:00
parent 0844bf2e47
commit 137cbbd186

View File

@@ -489,12 +489,15 @@ class WireInput extends Wire {
} else if(isset($_SERVER['REQUEST_URI'])) { } else if(isset($_SERVER['REQUEST_URI'])) {
// page not yet available, attempt to pull URL from 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']); $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) == '/') { if(!empty($info['path']) && substr($info['path'], -1) == '/') {
$url = rtrim($url, '/') . '/'; // trailing slash $url = rtrim($url, '/') . '/'; // trailing slash
} }