Improved Utils::url() to support query strings

This commit is contained in:
Andy Miller 2018-08-06 13:09:15 -06:00
parent 34fa50fcf0
commit 18d405d798
No known key found for this signature in database
GPG Key ID: E82B8D0EAB94EFB9
2 changed files with 12 additions and 3 deletions

View File

@ -4,7 +4,9 @@
1. [](#new)
* Added `Uri::method()` to get current HTTP method (GET/POST etc)
* `FormatterInterface`: Added `getSupportedFileExtensions()` and `getDefaultFileExtension()` methods
1. [](#improved)
* Improved `Utils::url()` to support query strings
# v1.5.0-rc.1
## 07/31/2018

View File

@ -45,8 +45,15 @@ abstract class Utils
/** @var UniformResourceLocator $locator */
$locator = Grav::instance()['locator'];
// Get relative path to the resource (or false if not found).
$resource = $locator->findResource($input, false);
$parts = Uri::parseUrl($input);
$resource = $locator->findResource("{$parts['scheme']}://{$parts['host']}{$parts['path']}", false);
if (isset($parts['query'])) {
$resource = $resource . '?' . $parts['query'];
}
} else {
$resource = $input;
}