Skip to content

Refactor: Use URLSearchParams instead of L.Util.template for query #838

Open
tbsmark86 wants to merge 1 commit intonrenner:masterfrom
tbsmark86:template_query
Open

Refactor: Use URLSearchParams instead of L.Util.template for query #838
tbsmark86 wants to merge 1 commit intonrenner:masterfrom
tbsmark86:template_query

Conversation

@tbsmark86
Copy link
Copy Markdown
Contributor

L.Util.template was missing url-escaping, while the values should never contain anything that needs escaping better safe then sorry.


Just a random bit I've stumbled over while trying to understand the code for something else.

…ilding

L.Util.template was missing url-escaping, while the values should never
contain anything that needs escaping better safe then sorry.
@mjaschen
Copy link
Copy Markdown
Contributor

mjaschen commented Aug 14, 2025

Here is double-escaping going on, which has to be fixed before merging. The call to encodeURIComponent() in

https://github.com/nrenner/brouter-web/blob/master/js/router/BRouter.js#L346

has to be removed.

Possible test case:

test('handles POI names with special characters', () => {
            const latLngs = [L.latLng(49.488117, 8.467712)];
            const pois = [{ latlng: L.latLng(49.4882, 8.4678), name: 'Café & Restaurant' }];

            const url = router.getUrl(latLngs, null, pois);

            expect(url).toContain('pois=8.4678%2C49.4882%2CCaf%C3%A9+%26+Restaurant');
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants