Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ export function joinURL(base: string | undefined, path: string | undefined): str
if (!base || base === "/") {
return path || "/";
}
if (!path || path === "/") {
return base || "/";
if (!path) {
return base;
}
// eslint-disable-next-line unicorn/prefer-at
const baseHasTrailing = base[base.length - 1] === "/";
Expand Down
8 changes: 8 additions & 0 deletions test/_utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,14 @@ describe("lib/http-proxy/common.js", () => {
it("should concat when base has trailing slash and path has no leading slash", () => {
expect(common.joinURL("/base/", "path")).to.eql("/base/path");
});

it("should preserve trailing slash when path is exactly /", () => {
expect(common.joinURL("/maildev", "/")).to.eql("/maildev/");
});

it("should keep a single trailing slash when both base ends and path is /", () => {
expect(common.joinURL("/maildev/", "/")).to.eql("/maildev/");
});
});

describe("#rewriteCookieProperty", () => {
Expand Down