Skip to content

Commit bf8ad5b

Browse files
authored
bug: fix clip views in cf worker (#431)
1 parent 888c170 commit bf8ad5b

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

  • cloudflare-workers/backblaze-proxy

cloudflare-workers/backblaze-proxy/index.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ function countClipPlay(
5454
if (!/^clips\/.+\.mp4$/.test(key)) {
5555
return;
5656
}
57-
if (url.searchParams.get("dl") === "1" || url.searchParams.get("download") === "1") {
57+
if (
58+
url.searchParams.get("dl") === "1" ||
59+
url.searchParams.get("download") === "1"
60+
) {
5861
return;
5962
}
6063
const range = request.headers.get("range");
@@ -107,6 +110,13 @@ export default {
107110
});
108111
}
109112

113+
const url = new URL(request.url);
114+
const key = resolveKey(url);
115+
116+
if (key) {
117+
countClipPlay(request, url, key, env, ctx);
118+
}
119+
110120
// Edge-cache short-circuit: serve repeat hits without re-running SigV4
111121
// or making a B2 subrequest. Range requests fall through so the existing
112122
// cf.cacheEverything path handles slicing from the cached full object.
@@ -124,8 +134,6 @@ export default {
124134
if (cached) return cached;
125135
}
126136

127-
const url = new URL(request.url);
128-
const key = resolveKey(url);
129137
if (!key) {
130138
return new Response("No file provided", { status: 400 });
131139
}
@@ -143,8 +151,6 @@ export default {
143151
);
144152
}
145153

146-
countClipPlay(request, url, key, env, ctx);
147-
148154
const signedRequest = await new AwsClient({
149155
accessKeyId: env.S3_ACCESS_KEY,
150156
secretAccessKey: env.S3_SECRET,

0 commit comments

Comments
 (0)