-
-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Hi,
Very cool library, but there are some issues with path concatenation.
new URL('c', 'https://a.com/b/')
. => https://a.com/b/c
new URL('/c', 'https://a.com/b/')
. => https://a.com/c
Which makes sense, but a lot of openapi specs use a base url with some sort of versioning or path like /v1
or even just /api
.
And then the spec itself contains paths like /contacts
which will be wrongly concatenated to the root instead of the base path.
For now I have manually removed the /
of the path var within PrepareFetchUrl like so:
PrepareFetchUrl(path: string): URL {
+ path = path.startsWith("/") ? path.slice(1) : path;
let base = this.Config.baseUrl;
if ("location" in globalThis && (base === "" || base.startsWith("/"))) {
const { location } = globalThis as unknown as {
location: { origin: string };
};
base = `${location.origin}${base.endsWith("/") ? base : `/${base}`}`;
}
return new URL(path, base);
}
Not sure if this is the best solution, but works for me.
Best,
JC
Metadata
Metadata
Assignees
Labels
No labels