Skip to content

Commit

Permalink
fix: Removing / won't work because / is default for rooted URL. Addin…
Browse files Browse the repository at this point in the history
…g slash instead.
  • Loading branch information
richtera committed Oct 10, 2023
1 parent ea2ae2f commit 9668b50
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/providers/url-converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export function createPrefixConverter(_gateway: string | URL, search?: string) {
if (!gateway.host || !gateway.protocol) {
throw new Error('Invalid gateway URL');
}
if (gateway.pathname.endsWith('/')) {
gateway.pathname = gateway.pathname.slice(0, -1);
if (!gateway.pathname.endsWith('/')) {
gateway.pathname = gateway.pathname + '/';
}
return (url: URL) => {
const base = `${gateway.pathname}/${url.hostname}${search || ''}`;
const base = `${gateway.pathname}${url.hostname}${search || ''}`;
return new URL(base, gateway);
};
}
Expand Down

0 comments on commit 9668b50

Please sign in to comment.