Skip to content
Snippets Groups Projects
Commit 6ebf8cbd authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

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.
parent 2cd86f2a
No related branches found
No related tags found
No related merge requests found
......@@ -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')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment