fix: trailing slash integration url issues (#1571)

This commit is contained in:
Meier Lukas
2024-11-30 10:54:50 +01:00
committed by GitHub
parent d5f76218cd
commit b277f444b2
19 changed files with 126 additions and 129 deletions

View File

@@ -1,12 +1,6 @@
import type { ReadonlyHeaders } from "next/dist/server/web/spec-extension/adapters/headers";
export const appendPath = (url: URL | string, path: string) => {
const newUrl = new URL(url);
newUrl.pathname = removeTrailingSlash(newUrl.pathname) + path;
return newUrl;
};
const removeTrailingSlash = (path: string) => {
export const removeTrailingSlash = (path: string) => {
return path.at(-1) === "/" ? path.substring(0, path.length - 1) : path;
};