OpenAPI: Fix trailing slashes being normalized

This commit is contained in:
Fuma Nama
2025-06-12 13:43:03 +08:00
parent 38d851c3f7
commit 201235fcd9
2 changed files with 9 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-openapi': patch
---
Fix trailing slashes being normalized
+4 -6
View File
@@ -1,13 +1,11 @@
import type { RequestData } from '@/requests/_shared';
export function joinURL(base: string, pathname: string): string {
pathname = pathname
.split('/')
.filter((v) => v.length > 0)
.join('/');
if (pathname.startsWith('/')) pathname = pathname.slice(1);
if (base.endsWith('/')) base = base.slice(0, -1);
if (!base.endsWith('/') && pathname.length > 0) base += '/';
return base + pathname;
if (pathname.length > 0) return base + '/' + pathname;
else return base;
}
/**