From e39e425ec47390069a220ac61ed9bdc5688af896 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Sun, 22 Aug 2021 21:46:49 +0200 Subject: [PATCH] Allow trailing slashes in seed API --- src/api.ts | 3 ++- src/config.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api.ts b/src/api.ts index 7984f9b2e..68c266633 100644 --- a/src/api.ts +++ b/src/api.ts @@ -14,8 +14,9 @@ export async function get( query[key] = val.toString(); } + const base = config.seed.api.replace(/\/$/, ""); const search = new URLSearchParams(query).toString(); - const baseUrl = `${config.seed.api}/v1/${path}`; + const baseUrl = `${base}/v1/${path}`; const url = search ? `${baseUrl}?${search}` : baseUrl; let response = null; diff --git a/src/config.ts b/src/config.ts index b0e55210e..71cfa55f6 100644 --- a/src/config.ts +++ b/src/config.ts @@ -129,7 +129,7 @@ export class Config { withSeed(seed: string): Config { const cfg = {} as Config; Object.assign(cfg, this); - cfg.seed.api = seed; + cfg.seed.api = seed.replace(/\/$/, ""); return cfg; }