Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
fix(Upload): double extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
ijsKoud committed Sep 12, 2023
1 parent 7fa21ad commit c5894e1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions apps/server/src/lib/Domains/Domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class Domain {

const fileData = await this.server.prisma.file.create({
data: {
id: this.nameStrategy === "zerowidth" ? id : `${id}.${fileExt}`,
id: this.nameStrategy === "zerowidth" || id.includes(".") ? id : `${id}.${fileExt}`,
authSecret,
date: new Date(),
mimeType: file.mimetype,
Expand All @@ -206,9 +206,8 @@ export class Domain {
}
});

const filename = `${fileData.id}${this.nameStrategy === "zerowidth" ? "" : `.${fileExt}`}`;
this.auditlogs.register("File Upload", `File: ${filename}, size: ${this.server.config.parseStorage(file.size)}`);
return filename;
this.auditlogs.register("File Upload", `File: ${fileData.id}, size: ${this.server.config.parseStorage(file.size)}`);
return fileData.id;
}

public async registerUpload(file: File, options: { name?: string; password?: string; visible?: boolean } = {}): Promise<string> {
Expand All @@ -224,7 +223,7 @@ export class Domain {

const fileData = await this.server.prisma.file.create({
data: {
id: this.nameStrategy === "zerowidth" ? id : `${id}.${fileExt}`,
id: this.nameStrategy === "zerowidth" || id.includes(".") ? id : `${id}.${fileExt}`,
authSecret,
date: new Date(),
mimeType: file.mimetype!,
Expand Down

0 comments on commit c5894e1

Please sign in to comment.