fix: incorrect polyline decoding
Don't split static image encoded path on pipe or comma Signed-off-by: boldtrn <boldtrn@gmail.com>
This commit is contained in:
parent
c13e5e6821
commit
eae747a8a4
2 changed files with 15 additions and 15 deletions
|
|
@ -162,21 +162,9 @@ const extractPathsFromQuery = (query, transformer) => {
|
|||
providedPath.includes('enc:') &&
|
||||
PATH_PATTERN.test(decodeURIComponent(providedPath))
|
||||
) {
|
||||
const encodedPaths = providedPath.split(',');
|
||||
for (const path of encodedPaths) {
|
||||
const line = path
|
||||
.split('|')
|
||||
.filter(
|
||||
(x) =>
|
||||
!x.startsWith('fill') &&
|
||||
!x.startsWith('stroke') &&
|
||||
!x.startsWith('width'),
|
||||
)
|
||||
.join('')
|
||||
.replace('enc:', '');
|
||||
const coords = polyline.decode(line).map(([lat, lng]) => [lng, lat]);
|
||||
paths.push(coords);
|
||||
}
|
||||
const encodedPaths = providedPath.replace('enc:', '');
|
||||
const coords = polyline.decode(encodedPaths).map(([lat, lng]) => [lng, lat]);
|
||||
paths.push(coords);
|
||||
} else {
|
||||
// Iterate through paths, parse and validate them
|
||||
const currentPath = [];
|
||||
|
|
|
|||
|
|
@ -171,6 +171,18 @@ describe('Static endpoints', function () {
|
|||
'?path=-10,-10|-20,-20',
|
||||
);
|
||||
});
|
||||
|
||||
describe('encoded path', function () {
|
||||
testStatic(
|
||||
prefix,
|
||||
'auto/20x20',
|
||||
'png',
|
||||
200,
|
||||
2,
|
||||
/image\/png/,
|
||||
'?path='+decodeURIComponent('enc:{{biGwvyGoUi@s_A|{@'),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('invalid requests return 4xx', function () {
|
||||
|
|
|
|||
Loading…
Reference in a new issue