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:
1 parent
8dceaec54a
commit
15ecda681f
3 files changed
+18
-2
No files matched your search
@@ -94,7 +94,8 @@ function buildAttachmentUrl(
|
||||
basePath?: string
|
||||
): string {
|
||||
const base = baseUrl ? `//${baseUrl}` : ''
|
||||
const prefix = basePath ? `/${basePath.replace(/^\/|\/$/g, '')}` : ''
|
||||
const segments = basePath ? basePath.replace(/^\/+|\/+$/g, '') : ''
|
||||
const prefix = segments ? `/${segments}` : ''
|
||||
return `${base}${prefix}/api/email/${emailId}/attachment/${encodeURIComponent(filename)}`
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user