From 0d6cf4907c10d20ee86ab454653af304c87e4596 Mon Sep 17 00:00:00 2001 From: Martin d'Allens Date: Thu, 28 Sep 2023 16:38:47 +0200 Subject: [PATCH] chore: cleanup useless decodeURIComponent() calls Signed-off-by: Martin d'Allens --- src/serve_rendered.js | 7 ++----- test/static.js | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/serve_rendered.js b/src/serve_rendered.js index 78648d5..9b70ddd 100644 --- a/src/serve_rendered.js +++ b/src/serve_rendered.js @@ -158,10 +158,7 @@ const extractPathsFromQuery = (query, transformer) => { // Iterate through paths, parse and validate them for (const providedPath of providedPaths) { // Logic for pushing coords to path when path includes google polyline - if ( - providedPath.includes('enc:') && - PATH_PATTERN.test(decodeURIComponent(providedPath)) - ) { + if (providedPath.includes('enc:') && PATH_PATTERN.test(providedPath)) { // +4 because 'enc:' is 4 characters, everything after 'enc:' is considered to be part of the polyline const encIndex = providedPath.indexOf('enc:') + 4; const coords = polyline @@ -432,7 +429,7 @@ const drawMarkers = async (ctx, markers, z) => { * @param {number} z Map zoom level. */ const drawPath = (ctx, path, query, pathQuery, z) => { - const splitPaths = decodeURIComponent(pathQuery).split('|'); + const splitPaths = pathQuery.split('|'); if (!path || path.length < 2) { return null; diff --git a/test/static.js b/test/static.js index 302becb..32bd80c 100644 --- a/test/static.js +++ b/test/static.js @@ -180,7 +180,7 @@ describe('Static endpoints', function () { 200, 2, /image\/png/, - '?path=' + decodeURIComponent('enc:{{biGwvyGoUi@s_A|{@'), + '?path=' + encodeURIComponent('enc:{{biGwvyGoUi@s_A|{@'), ); }); });