From 3b5ac6aca3d78c2b21902a72886528e7ec69dc45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ga=C5=82=C4=99=C5=BCewski?= <35779884+PanMisza@users.noreply.github.com> Date: Sun, 5 May 2024 20:52:12 +0200 Subject: [PATCH 1/2] fix: ensure base path ends with '/' --- src/utils.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 64fa6f39..e2d64755 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -5,9 +5,15 @@ export function slash(str: string) { export function resolveBasePath(base: string) { if (isAbsolute(base)) return base - return (!base.startsWith('/') && !base.startsWith('./')) - ? `/${base}` - : base + + let basePath = base + if (!basePath.endsWith('/')) + basePath = `${basePath}/` + + if (!basePath.startsWith('/') && !basePath.startsWith('./')) + basePath = `/${basePath}` + + return basePath } export function isAbsolute(url: string) { From 1892bedf6c99327ea0ed1b97e56fe1c45e9e461b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ga=C5=82=C4=99=C5=BCewski?= <35779884+PanMisza@users.noreply.github.com> Date: Sun, 5 May 2024 21:14:17 +0200 Subject: [PATCH 2/2] fix: ensure absolute base path ends with '/' --- src/utils.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index e2d64755..83abc902 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -3,13 +3,14 @@ export function slash(str: string) { } export function resolveBasePath(base: string) { - if (isAbsolute(base)) - return base - let basePath = base + if (!basePath.endsWith('/')) basePath = `${basePath}/` + if (isAbsolute(basePath)) + return basePath + if (!basePath.startsWith('/') && !basePath.startsWith('./')) basePath = `/${basePath}`