From fb6627b2ba15f9f30a1bcd588bd503e2a3f97ad2 Mon Sep 17 00:00:00 2001 From: oscarotero Date: Fri, 11 Mar 2016 10:06:48 +0100 Subject: [PATCH] fixed saveResponse and readResponse with paths with unicode chars --- src/Utils/FileTrait.php | 3 ++- tests/SaveReadResponseTest.php | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Utils/FileTrait.php b/src/Utils/FileTrait.php index 91a276a..8a15860 100644 --- a/src/Utils/FileTrait.php +++ b/src/Utils/FileTrait.php @@ -53,7 +53,8 @@ public function appendQuery($appendQuery = true) */ private function getFilename(RequestInterface $request, $indexExt = 'html') { - $parts = pathinfo($request->getUri()->getPath()); + $path = urldecode($request->getUri()->getPath()); + $parts = pathinfo($path); $path = isset($parts['dirname']) ? $parts['dirname'] : ''; $filename = isset($parts['basename']) ? $parts['basename'] : ''; diff --git a/tests/SaveReadResponseTest.php b/tests/SaveReadResponseTest.php index 5dc0db4..fb9fa3c 100644 --- a/tests/SaveReadResponseTest.php +++ b/tests/SaveReadResponseTest.php @@ -11,15 +11,23 @@ public function saveProvider() '/hello-world', '/hello-world/index.html', 'Hello world', - ], [ + ], + [ '/post', '/post/index.html', 'This is a post', - ], [ + ], + [ + '/Os miúdos camiños', + '/Os miúdos camiños/index.html', + 'This is a post with spaces and tildes', + ], + [ '/index.json', '/index.json', '{"hello": "world"}', - ], [ + ], + [ '/', '/index.html', 'Index',