fix: still allow other parameters other than enc:

That way we can still style individual paths

Signed-off-by: boldtrn <boldtrn@gmail.com>
This commit is contained in:
boldtrn 2023-09-26 14:56:54 +02:00 committed by Andrew Calcutt
parent eae747a8a4
commit 30f2f7a40f

View file

@ -162,8 +162,9 @@ const extractPathsFromQuery = (query, transformer) => {
providedPath.includes('enc:') && providedPath.includes('enc:') &&
PATH_PATTERN.test(decodeURIComponent(providedPath)) PATH_PATTERN.test(decodeURIComponent(providedPath))
) { ) {
const encodedPaths = providedPath.replace('enc:', ''); // +4 because enc: are 4 characters, everything after enc: is considered to be part of the polyline
const coords = polyline.decode(encodedPaths).map(([lat, lng]) => [lng, lat]); const encIndex = providedPath.indexOf('enc:') + 4;
const coords = polyline.decode(providedPath.substring(encIndex)).map(([lat, lng]) => [lng, lat]);
paths.push(coords); paths.push(coords);
} else { } else {
// Iterate through paths, parse and validate them // Iterate through paths, parse and validate them