Skip to content

Commit

Permalink
fixed(core): ensure valid URL is used for all IMLProvider delete feat…
Browse files Browse the repository at this point in the history
…ure requests

Signed-off-by: Tim Deubler <[email protected]>
  • Loading branch information
TerminalTim committed Sep 5, 2024
1 parent 534fc28 commit 5eb99bc
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/core/src/providers/GeoSpace/SpaceProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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 || '&');
};


Expand Down

0 comments on commit 5eb99bc

Please sign in to comment.