From 1b68b603d9a30b44c908e773201828b047c77048 Mon Sep 17 00:00:00 2001 From: Pekka Helesuo Date: Thu, 12 Dec 2024 13:16:29 +0200 Subject: [PATCH 1/2] return decoded value from url cleanup function --- .../view/ServiceEndPoint/ServiceUrlInputHelper.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bundles/admin/admin-layereditor/view/ServiceEndPoint/ServiceUrlInputHelper.js b/bundles/admin/admin-layereditor/view/ServiceEndPoint/ServiceUrlInputHelper.js index f648974040..f4f06593ba 100644 --- a/bundles/admin/admin-layereditor/view/ServiceEndPoint/ServiceUrlInputHelper.js +++ b/bundles/admin/admin-layereditor/view/ServiceEndPoint/ServiceUrlInputHelper.js @@ -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; }; From 5ad5990f3a6a23ec6d208727b366d7577b739a93 Mon Sep 17 00:00:00 2001 From: Pekka Helesuo Date: Thu, 12 Dec 2024 13:28:22 +0200 Subject: [PATCH 2/2] add unit tests --- .../view/ServiceEndPoint/ServiceUrlInputHelper.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bundles/admin/admin-layereditor/view/ServiceEndPoint/ServiceUrlInputHelper.test.js b/bundles/admin/admin-layereditor/view/ServiceEndPoint/ServiceUrlInputHelper.test.js index 885e0ff91d..e9684d8a4f 100644 --- a/bundles/admin/admin-layereditor/view/ServiceEndPoint/ServiceUrlInputHelper.test.js +++ b/bundles/admin/admin-layereditor/view/ServiceEndPoint/ServiceUrlInputHelper.test.js @@ -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); + }); }); });