From 6ebf8cbda675c6477dfe7a6794fe0537f6421af8 Mon Sep 17 00:00:00 2001 From: Konrad Mohrfeldt <konrad.mohrfeldt@farbdev.org> Date: Mon, 5 Dec 2022 18:51:44 +0100 Subject: [PATCH] fix: fix URL builder issues * basepath normalization: String.replace is not in-place. * params: unshift adds array items, we wanted to pop the last item. --- src/store/api-helper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/store/api-helper.js b/src/store/api-helper.js index 5117dcf9..25171793 100644 --- a/src/store/api-helper.js +++ b/src/store/api-helper.js @@ -90,12 +90,12 @@ export function callOrReturn(response, callback) { function createURLBuilder(basepath, useTrailingSlash = true) { // Strip all trailing slashes from the basepath. // We handle slashes when building URLs. - basepath.replace(/\/*$/, '') + basepath = basepath.replace(/\/*$/, '') return function buildURL(...subPaths) { let params if (subPaths.at(-1) instanceof URLSearchParams) { - params = subPaths.unshift() + params = subPaths.pop() } if (subPaths.some((path) => String(path).includes('/'))) { throw new Error('Subpaths must not contain slashes') -- GitLab