1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-15 11:14:12 +02:00

Fix issue in Paths.php where getting URL for 'http[ModuleName]' incorrectly returned error

This commit is contained in:
Ryan Cramer
2020-03-25 09:27:37 -04:00
parent 278d323acd
commit f54342a20c

View File

@@ -162,6 +162,7 @@ class Paths extends WireData {
static $_http = null; static $_http = null;
if($key === 'root') return $this->_root; if($key === 'root') return $this->_root;
$http = ''; $http = '';
$altKey = '';
if(is_object($key)) { if(is_object($key)) {
$key = "$key"; $key = "$key";
} else if(strpos($key, 'http') === 0) { } else if(strpos($key, 'http') === 0) {
@@ -172,14 +173,18 @@ class Paths extends WireData {
if($httpHost) $_http = "$scheme://$httpHost"; if($httpHost) $_http = "$scheme://$httpHost";
} }
$http = $_http; $http = $_http;
$key = substr($key, 4); $key = substr($key, 4); // httpTemplates => Templates
$key[0] = strtolower($key[0]); $altKey = $key; // no lowercase conversion (useful for keys like module names, i.e. 'ProcessPageEdit')
$key[0] = strtolower($key[0]); // first character lowercase: Templates => templates
} }
if($key === 'root') { if($key === 'root') {
$value = $http . $this->_root; $value = $http . $this->_root;
} else { } else {
$value = parent::get($key); $value = parent::get($key);
if($value === null || !strlen($value)) return $value; if($value === null || !strlen($value)) {
if($altKey) $value = parent::get($altKey);
if(empty($value)) return $value;
}
$pos = strpos($value, '//'); $pos = strpos($value, '//');
if($pos !== false && ($pos === 0 || ($pos > 0 && $value[$pos-1] === ':'))) { if($pos !== false && ($pos === 0 || ($pos > 0 && $value[$pos-1] === ':'))) {
// fully qualified URL // fully qualified URL