mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-28 15:10:55 -05:00
refactor(s3-backend): use URL object to construct complete URL instead of string template
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
b6db47a9c2
commit
0950e036b0
1 changed files with 5 additions and 3 deletions
|
@ -73,8 +73,10 @@ export class S3Backend implements MediaBackend {
|
||||||
|
|
||||||
private getUrl(fileName: string): string {
|
private getUrl(fileName: string): string {
|
||||||
const url = new URL(this.config.endPoint);
|
const url = new URL(this.config.endPoint);
|
||||||
const port = url.port !== '' ? `:${url.port}` : '';
|
if (!url.pathname.endsWith('/')) {
|
||||||
const bucket = this.config.bucket;
|
url.pathname += '/';
|
||||||
return `${url.protocol}//${url.hostname}${port}${url.pathname}${bucket}/${fileName}`;
|
}
|
||||||
|
url.pathname += `${this.config.bucket}/${fileName}`;
|
||||||
|
return url.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue