Skip to content

Commit

Permalink
fix: serve index.tab files as text files
Browse files Browse the repository at this point in the history
Signed-off-by: flakey5 <[email protected]>
  • Loading branch information
flakey5 committed Dec 24, 2024
1 parent a6eb1f4 commit e889b07
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/providers/r2Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,19 @@ function r2MetadataToHeaders(
): HttpResponseHeaders {
const { httpMetadata } = object;

let contentType: string;
if (object.httpMetadata?.contentType !== undefined) {
contentType = object.httpMetadata.contentType;
} else {
// Serve .tab files as text files
contentType = object.key.endsWith('.tab')
? 'text/plain'
: 'application/octet-stream';
}

return {
etag: object.httpEtag,
'content-type':
object.httpMetadata?.contentType ?? 'application/octet-stream',
'content-type': contentType,
'accept-range': 'bytes',
// https://github.com/nodejs/build/blob/e3df25d6a23f033db317a53ab1e904c953ba1f00/ansible/www-standalone/resources/config/nodejs.org?plain=1#L194-L196
'access-control-allow-origin': object.key.endsWith('.json') ? '*' : '',
Expand Down

0 comments on commit e889b07

Please sign in to comment.