mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
OpenAPI: Fix trailing slashes being normalized
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-openapi': patch
|
||||
---
|
||||
|
||||
Fix trailing slashes being normalized
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user