From 7d288b803e07557145bf5ca2e1c0ce654cac081f Mon Sep 17 00:00:00 2001 From: flakey5 <73616808+flakey5@users.noreply.github.com> Date: Mon, 23 Dec 2024 21:43:10 -0800 Subject: [PATCH] fix: serve index.tab files as text files Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com> --- src/providers/r2Provider.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/providers/r2Provider.ts b/src/providers/r2Provider.ts index c72114a..6fb3a21 100644 --- a/src/providers/r2Provider.ts +++ b/src/providers/r2Provider.ts @@ -98,10 +98,19 @@ function r2MetadataToHeaders( ): HttpResponseHeaders { const { httpMetadata } = object; + let contentType: string; + if (object.httpMetadata?.contentType) { + 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') ? '*' : '',