Skip to content

Commit

Permalink
Merge pull request #2762 from DenverCoder544/layerhandler_url_clean_e…
Browse files Browse the repository at this point in the history
…ncode_bug

Layerhandler url clean encode bug
  • Loading branch information
ZakarFin authored Dec 13, 2024
2 parents da3d9b9 + 5ad5990 commit 0d255e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ export const cleanUrl = (url) => {
keysToDelete.forEach((key) => urlObj.searchParams.delete(key));

const parts = urlObj.toString().split('://');
if (parts.length > 1) {
return parts[1];
}

return urlObj.toString();
const retValString = parts.length > 1 ? parts[1] : urlObj.toString();
const decoded = decodeURIComponent(retValString);
return decoded;
};
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,13 @@ describe('ServiceUrlInputHelper Tests ', () => {
const url = 'www.com/';
expect(cleanUrl(url)).toBe(url);
});

it('should NOT encode URL params', () => {
const url = 'avoin-karttakuva.maanmittauslaitos.fi/kiinteisto-avoin/tiles/wmts/1.0.0/kiinteistojaotus/default/v3/ETRS-TM35FIN/{z}/{y}/{x}.pbf';
expect(cleanUrl(url)).toBe(url);

const url2 = 'www.com/?first=1&SECOND=2&thiRd=3';
expect(cleanUrl(url2)).toBe(url2);
});
});
});

0 comments on commit 0d255e1

Please sign in to comment.