diff --git a/CHANGELOG.md b/CHANGELOG.md index 29e3f37da..ba9a42072 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ * Checkbox getting interpreted as string, so created new `Validation::filterCheckbox()` * Fixed backwards compatibility to `select` field with `selectize.create` set to true [git-sync#141](https://github.com/trilbymedia/grav-plugin-git-sync/issues/141) * Fixed `YamlFormatter::decode()` to always return array [#2494](https://github.com/getgrav/grav/pull/2494) + * Fixed empty `$grav['request']->getAttribute('route')->getExtension()` # v1.6.8 ## 04/23/2019 diff --git a/system/src/Grav/Common/Processors/RequestProcessor.php b/system/src/Grav/Common/Processors/RequestProcessor.php index 8cb876a39..97564e69b 100644 --- a/system/src/Grav/Common/Processors/RequestProcessor.php +++ b/system/src/Grav/Common/Processors/RequestProcessor.php @@ -30,10 +30,13 @@ class RequestProcessor extends ProcessorBase $request = $request->withParsedBody(json_decode($request->getBody()->getContents(), true)); } + $uri = $request->getUri(); + $ext = mb_strtolower(pathinfo($uri->getPath(), PATHINFO_EXTENSION)); + $request = $request ->withAttribute('grav', $this->container) ->withAttribute('time', $_SERVER['REQUEST_TIME_FLOAT'] ?? GRAV_REQUEST_TIME) - ->withAttribute('route', Uri::getCurrentRoute()) + ->withAttribute('route', Uri::getCurrentRoute()->withExtension($ext)) ->withAttribute('referrer', $this->container['uri']->referrer()); $event = new RequestHandlerEvent(['request' => $request, 'handler' => $handler]); diff --git a/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php b/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php index d95774f03..6d3f873de 100644 --- a/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php +++ b/system/src/Grav/Framework/Flex/Traits/FlexMediaTrait.php @@ -229,7 +229,6 @@ trait FlexMediaTrait } // Remove Extra Files - foreach (scandir($targetPath, SCANDIR_SORT_NONE) as $file) { $preg_name = preg_quote($fileParts['filename'], '`'); $preg_ext =preg_quote($fileParts['extension'], '`');