Skip to content
This repository was archived by the owner on Feb 23, 2025. It is now read-only.

Commit a6f2a0a

Browse files
committed
feat: return .ext to user if header is set
1 parent 92a37a4 commit a6f2a0a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/routers/upload.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,12 @@ router.post('/', (req: Request, res: Response, next: Function) => {
121121
const uploader = findFromToken(req.token)?.username ?? 'Unknown';
122122
log.success('File uploaded', logInfo, `uploaded by ${uploader}`);
123123

124+
// ! random thing for 0.14.8 to append the file extension to the resource url
125+
const extAppend = !(req.headers['x-ass-with-file-ext']?.toString() ?? false) ? ''
126+
: `.${req.file.originalname.split('.').pop()}`;
127+
124128
// Build the URLs
125-
const resourceUrl = `${getTrueHttp()}${trueDomain}/${resourceId}`;
129+
const resourceUrl = `${getTrueHttp()}${trueDomain}/${resourceId}${extAppend}`;
126130
const thumbnailUrl = `${getTrueHttp()}${trueDomain}/${resourceId}/thumbnail`;
127131
const deleteUrl = `${getTrueHttp()}${trueDomain}/${resourceId}/delete/${req.file.deleteId}`;
128132

0 commit comments

Comments
 (0)