From 5eb99bcb7c7ee2a136c0efa2d78d353e05495b35 Mon Sep 17 00:00:00 2001 From: Tim Deubler Date: Thu, 5 Sep 2024 17:04:32 +0200 Subject: [PATCH] fixed(core): ensure valid URL is used for all IMLProvider delete feature requests Signed-off-by: Tim Deubler --- .../core/src/providers/GeoSpace/SpaceProvider.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/core/src/providers/GeoSpace/SpaceProvider.ts b/packages/core/src/providers/GeoSpace/SpaceProvider.ts index 283fddcb0..9ead518f5 100644 --- a/packages/core/src/providers/GeoSpace/SpaceProvider.ts +++ b/packages/core/src/providers/GeoSpace/SpaceProvider.ts @@ -41,7 +41,8 @@ const ENDPOINT = { type Parameter = string | number | boolean; const addUrlParams = (url: string, params: { [key: string]: Parameter | Parameter[] }, p?: '?' | '&') => { - p ||= url.indexOf('?=') == -1 ? '?' : '&'; + p ||= url.includes('?') ? '&' : '?'; + // p ||= new URL(url).searchParams.size ? '&' : '?'; const encodeParam = (param: Parameter | Parameter[]): string => { return Array.isArray(param) ? param.map((p: string) => encodeURIComponent(p)).join(',') : encodeURIComponent(param); }; @@ -247,12 +248,13 @@ export class SpaceProvider extends GeoJSONProvider { error?: (error: any) => void } = {}) { const prov = this; - const url = prov._addUrlCredentials( - prov.getLayerUrl(prov.space) + '/features', '?' + const url = addUrlParams( + prov.getLayerUrl(prov.space) + '/features', + {id: features.map((f) => f.id)} ); return { type: 'DELETE', - url: addUrlParams(url, {id: features.map((f) => f.id)}), + url: prov._addUrlCredentials(url), headers: { ...prov.headers, 'Accept': 'application/json' @@ -495,8 +497,7 @@ export class SpaceProvider extends GeoJSONProvider { private _addUrlCredentials(url: string, p?: '?' | '&') { - url = addUrlParams(url, this.params, p || '&'); - return url; + return addUrlParams(url, this.params, p || '&'); };