mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-05-18 15:44:45 +02:00
fix: don't declare Accept-Ranges: none for binary files
The server set Accept-Ranges: none on every file response. For text we anonymize on the fly so byte ranges aren't meaningful, but binary entries pass through unchanged — and the explicit "none" header makes some browsers refuse to play <video>/<audio> elements that would otherwise fall back to a full download. Newly uploaded MP4s under the inline-preview threshold rendered as a blank progress bar (#538). Only set Accept-Ranges: none for text entries; let binary entries omit it so the standard fallback kicks in. Fixes #538.
This commit is contained in:
@@ -66,7 +66,13 @@ router.post("/", async (req: express.Request, res: express.Response) => {
|
||||
} else if (isTextFile(filePath)) {
|
||||
res.contentType("text/plain");
|
||||
}
|
||||
res.header("Accept-Ranges", "none");
|
||||
// Only declare Accept-Ranges: none for text files — they get rewritten on
|
||||
// the fly so byte ranges aren't meaningful. For binary entries the
|
||||
// transformer is a passthrough; let <video>/<audio> fall back to a full
|
||||
// download instead of refusing to play (#538).
|
||||
if (isTextFile(filePath)) {
|
||||
res.header("Accept-Ranges", "none");
|
||||
}
|
||||
anonymizer.once("transform", (data) => {
|
||||
if (!mime && data.isText) {
|
||||
res.contentType("text/plain");
|
||||
|
||||
Reference in New Issue
Block a user