Skip to content

Commit 7d288b8

Browse files
committed
fix: serve index.tab files as text files
Signed-off-by: flakey5 <[email protected]>
1 parent a6eb1f4 commit 7d288b8

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/providers/r2Provider.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,19 @@ function r2MetadataToHeaders(
9898
): HttpResponseHeaders {
9999
const { httpMetadata } = object;
100100

101+
let contentType: string;
102+
if (object.httpMetadata?.contentType) {
103+
contentType = object.httpMetadata.contentType;
104+
} else {
105+
// Serve .tab files as text files
106+
contentType = object.key.endsWith('.tab')
107+
? 'text/plain'
108+
: 'application/octet-stream';
109+
}
110+
101111
return {
102112
etag: object.httpEtag,
103-
'content-type':
104-
object.httpMetadata?.contentType ?? 'application/octet-stream',
113+
'content-type': contentType,
105114
'accept-range': 'bytes',
106115
// https://github.com/nodejs/build/blob/e3df25d6a23f033db317a53ab1e904c953ba1f00/ansible/www-standalone/resources/config/nodejs.org?plain=1#L194-L196
107116
'access-control-allow-origin': object.key.endsWith('.json') ? '*' : '',

0 commit comments

Comments
 (0)