fix: omit the base path prefix when it resolves to the root

A caller passing basePath '/' produced //api/email/..., which a browser reads as a protocol-relative URL rather than a path. Strip the slashes first and only add a prefix when something is left.
This commit is contained in:
dualfroz committed 2026-09-17 16:18:50 +02:00
1 parent 8dceaec54a
commit 15ecda681f
3 files changed
+18 -2

No files matched your search

+2 -1
View File
@@ -7,4 +7,5 @@ Fix the URL that `replaceCidReferences` rewrites inline (CID) attachments to. It
built `/email/:id/attachment/:file`, which matches no route: the attachment is
served from `/api/email/:id/attachment/:file`, under the configured base path.
The URL is now root-relative and includes both parts, so it resolves at the root
and under a subpath such as `/mail`.
and under a subpath such as `/mail`. A base path that resolves to the root (`/`)
adds no prefix, so it can no longer produce a protocol-relative `//api/email/...`.