chore: cleanup useless decodeURIComponent() calls

Signed-off-by: Martin d'Allens <martin.dallens@liberty-rider.com>
This commit is contained in:
Martin d'Allens 2023-09-28 16:38:47 +02:00
parent 9348350ba3
commit 0d6cf4907c
2 changed files with 3 additions and 6 deletions

View file

@ -158,10 +158,7 @@ const extractPathsFromQuery = (query, transformer) => {
// Iterate through paths, parse and validate them // Iterate through paths, parse and validate them
for (const providedPath of providedPaths) { for (const providedPath of providedPaths) {
// Logic for pushing coords to path when path includes google polyline // Logic for pushing coords to path when path includes google polyline
if ( if (providedPath.includes('enc:') && PATH_PATTERN.test(providedPath)) {
providedPath.includes('enc:') &&
PATH_PATTERN.test(decodeURIComponent(providedPath))
) {
// +4 because 'enc:' is 4 characters, everything after 'enc:' is considered to be part of the polyline // +4 because 'enc:' is 4 characters, everything after 'enc:' is considered to be part of the polyline
const encIndex = providedPath.indexOf('enc:') + 4; const encIndex = providedPath.indexOf('enc:') + 4;
const coords = polyline const coords = polyline
@ -432,7 +429,7 @@ const drawMarkers = async (ctx, markers, z) => {
* @param {number} z Map zoom level. * @param {number} z Map zoom level.
*/ */
const drawPath = (ctx, path, query, pathQuery, z) => { const drawPath = (ctx, path, query, pathQuery, z) => {
const splitPaths = decodeURIComponent(pathQuery).split('|'); const splitPaths = pathQuery.split('|');
if (!path || path.length < 2) { if (!path || path.length < 2) {
return null; return null;

View file

@ -180,7 +180,7 @@ describe('Static endpoints', function () {
200, 200,
2, 2,
/image\/png/, /image\/png/,
'?path=' + decodeURIComponent('enc:{{biGwvyGoUi@s_A|{@'), '?path=' + encodeURIComponent('enc:{{biGwvyGoUi@s_A|{@'),
); );
}); });
}); });