From 9048927c892745ba4179e168267b76be1fc9011b Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 19 May 2024 21:47:09 +0200 Subject: [PATCH] Fix api path slash cleanup --- front/packages/models/src/query.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/front/packages/models/src/query.tsx b/front/packages/models/src/query.tsx index d75b38f3..ec4f4937 100644 --- a/front/packages/models/src/query.tsx +++ b/front/packages/models/src/query.tsx @@ -33,8 +33,9 @@ import { type Page, Paged } from "./page"; export let lastUsedUrl: string = null!; -const cleanSlash = (str: string | null) => { +const cleanSlash = (str: string | null, keepFirst = false) => { if (!str) return null; + if (keepFirst) return str.replace(/\/$/g, ""); return str.replace(/^\/|\/$/g, ""); }; @@ -59,7 +60,7 @@ export const queryFn = async ( lastUsedUrl = url!; const token = iToken === undefined && context.authenticated !== false ? await getToken() : iToken; - const path = [cleanSlash(url)] + const path = [cleanSlash(url, true)] .concat( "path" in context ? (context.path as string[])