Shift REQUEST_URI mangling into HTTPRequestBuilder::createFromVariables()

This commit is contained in:
Damian Mooyman 2017-10-09 17:35:33 +13:00
parent 199d607a2c
commit 3e6984d5a8
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A

View File

@ -32,7 +32,13 @@ class HTTPRequestBuilder
*/
public static function createFromVariables(array $variables, $input)
{
$url = $variables['_SERVER']['REQUEST_URI'];
// Remove query parameters (they're retained separately through $server['_GET']
$url = parse_url($variables['_SERVER']['REQUEST_URI'], PHP_URL_PATH);
// Remove base folders from the URL if webroot is hosted in a subfolder
if (substr(strtolower($url), 0, strlen(BASE_URL)) === strtolower(BASE_URL)) {
$url = substr($url, strlen(BASE_URL));
}
// Build request
$request = new HTTPRequest(
@ -124,17 +130,6 @@ class HTTPRequestBuilder
(array)$variables['_COOKIE']
);
// Remove query parameters (they're retained separately through $server['_GET']
$url = parse_url($variables['_SERVER']['REQUEST_URI'], PHP_URL_PATH);
// Remove base folders from the URL if webroot is hosted in a subfolder
if (substr(strtolower($url), 0, strlen(BASE_URL)) === strtolower(BASE_URL)) {
$url = substr($url, strlen(BASE_URL));
}
// Normalise URI
$variables['_SERVER']['REQUEST_URI'] = $url;
return $variables;
}
}