Skip to content

Commit f23e09c

Browse files
committed
feat: update content type checking
1 parent 5e58540 commit f23e09c

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

function/app.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,9 @@ export const lambdaHandler = async (event: LambdaFunctionURLEvent): Promise<Lamb
137137
* @returns {boolean} - true if the headers have the correct content-type, false otherwise
138138
*/
139139
function hasValidContentType(headers: Record<string, string | undefined>): boolean {
140-
const contentType = ['content-type', 'Content-Type', 'CONTENT-TYPE'];
141-
142-
for (const key of contentType) {
143-
if (headers[key] === ACCEPTABLE_CONTENT_TYPE) {
144-
return true;
145-
}
146-
}
147-
148-
return false;
140+
return Object.entries(headers).some(
141+
([key, value]) => key.toLowerCase() === 'content-type' && value?.toLowerCase().startsWith(ACCEPTABLE_CONTENT_TYPE),
142+
);
149143
}
150144

151145
/**

0 commit comments

Comments
 (0)