Skip to content

Commit 003bb28

Browse files
committed
use isBinaryContentType
1 parent e51eff5 commit 003bb28

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Diff for: packages/open-next/src/adapters/cache.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from "@aws-sdk/client-s3";
1414
import path from "path";
1515

16+
import { isBinaryContentType } from "./binary.js";
1617
import { MAX_DYNAMO_BATCH_WRITE_ITEM_COUNT } from "./constants.js";
1718
import { debug, error, warn } from "./logger.js";
1819
import { chunk } from "./util.js";
@@ -228,7 +229,7 @@ export default class S3Cache {
228229
kind: "ROUTE",
229230
body: Buffer.from(
230231
cacheData.body ?? Buffer.alloc(0),
231-
String(meta?.headers?.["content-type"]).startsWith("image")
232+
isBinaryContentType(String(meta?.headers?.["content-type"]))
232233
? "base64"
233234
: "utf8",
234235
),
@@ -282,7 +283,7 @@ export default class S3Cache {
282283
JSON.stringify({
283284
type: "route",
284285
body: body.toString(
285-
String(headers["content-type"]).startsWith("image")
286+
isBinaryContentType(String(headers["content-type"]))
286287
? "base64"
287288
: "utf8",
288289
),

Diff for: packages/open-next/src/build.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
buildSync,
1111
} from "esbuild";
1212

13+
import { isBinaryContentType } from "./adapters/binary.js";
1314
import logger from "./logger.js";
1415
import { minifyAll } from "./minimize-js.js";
1516
import openNextPlugin from "./plugin.js";
@@ -509,7 +510,7 @@ function createCacheAssets(monorepoRoot: string, disableDynamoDBCache = false) {
509510
? fs
510511
.readFileSync(files.body)
511512
.toString(
512-
cacheFileMeta.headers["content-type"].startsWith("image")
513+
isBinaryContentType(cacheFileMeta.headers["content-type"])
513514
? "base64"
514515
: "utf8",
515516
)

0 commit comments

Comments
 (0)