Skip to content

Commit

Permalink
feat: return .ext to user if header is set
Browse files Browse the repository at this point in the history
  • Loading branch information
tycrek committed Jan 10, 2024
1 parent 92a37a4 commit a6f2a0a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/routers/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,12 @@ router.post('/', (req: Request, res: Response, next: Function) => {
const uploader = findFromToken(req.token)?.username ?? 'Unknown';
log.success('File uploaded', logInfo, `uploaded by ${uploader}`);

// ! random thing for 0.14.8 to append the file extension to the resource url
const extAppend = !(req.headers['x-ass-with-file-ext']?.toString() ?? false) ? ''
: `.${req.file.originalname.split('.').pop()}`;

// Build the URLs
const resourceUrl = `${getTrueHttp()}${trueDomain}/${resourceId}`;
const resourceUrl = `${getTrueHttp()}${trueDomain}/${resourceId}${extAppend}`;
const thumbnailUrl = `${getTrueHttp()}${trueDomain}/${resourceId}/thumbnail`;
const deleteUrl = `${getTrueHttp()}${trueDomain}/${resourceId}/delete/${req.file.deleteId}`;

Expand Down

0 comments on commit a6f2a0a

Please sign in to comment.