Skip to content

Commit 6bb76cb

Browse files
committed
Reducing errors in logs
1 parent b8d3b07 commit 6bb76cb

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "labelzoom-cf-api-proxy",
3-
"version": "1.0.12",
3+
"version": "1.0.13",
44
"private": true,
55
"scripts": {
66
"deploy": "wrangler deploy",

src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
import { handleOptions, responseWithAllowOrigin } from "./cors";
1515

16+
const LABEL_CONVERSION_PATH_PATTERN = /^\/api\/v2\/convert\/[a-z]+\/to\/[a-z]+\/?$/i;
17+
1618
function getContentType(fileExtension: string): string | undefined {
1719
switch (fileExtension) {
1820
case "json": return "application/json";
@@ -25,8 +27,8 @@ function getContentType(fileExtension: string): string | undefined {
2527
case "gif": return "image/gif";
2628
case "bmp": return "image/bmp";
2729
case "pdf": return "application/pdf";
30+
default: return undefined;
2831
}
29-
return undefined;
3032
}
3133

3234
/**
@@ -119,7 +121,7 @@ export default {
119121
// Handle CORS preflight requests
120122
return handleOptions(request, env);
121123
}
122-
if (url.pathname.startsWith('/api/v2/convert/')) {
124+
if (LABEL_CONVERSION_PATH_PATTERN.test(url.pathname)) {
123125
return responseWithAllowOrigin(
124126
await handleConversionLog(request, env, ctx, url),
125127
request.headers.get('Origin') ?? '*'

0 commit comments

Comments
 (0)