diff --git a/packages/qwik-city/src/middleware/request-handler/resolve-request-handlers.ts b/packages/qwik-city/src/middleware/request-handler/resolve-request-handlers.ts index e6e582b9e60..1ba0ef5b3f3 100644 --- a/packages/qwik-city/src/middleware/request-handler/resolve-request-handlers.ts +++ b/packages/qwik-city/src/middleware/request-handler/resolve-request-handlers.ts @@ -597,6 +597,6 @@ export async function measure( } export function isContentType(headers: Headers, ...types: string[]) { - const type = headers.get('content-type')?.split(/;,/, 1)[0].trim() ?? ''; + const type = headers.get('content-type')?.split(/;/, 1)[0].trim() ?? ''; return types.includes(type); } diff --git a/packages/qwik-city/src/middleware/request-handler/resolve-request-handlers.unit.ts b/packages/qwik-city/src/middleware/request-handler/resolve-request-handlers.unit.ts index 154399a5896..fd6e49bfaf6 100644 --- a/packages/qwik-city/src/middleware/request-handler/resolve-request-handlers.unit.ts +++ b/packages/qwik-city/src/middleware/request-handler/resolve-request-handlers.unit.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest'; -import { getPathname } from './resolve-request-handlers'; +import { getPathname, isContentType } from './resolve-request-handlers'; describe('resolve-request-handler', () => { describe('getPathname', () => { @@ -30,4 +30,14 @@ describe('resolve-request-handler', () => { ); }); }); + + describe('isContentType', () => { + it('should correctly identify form/data', () => { + const headers = new Headers({ + 'content-type': + 'multipart/form-data; boundary=---------------------------5509475224001460121912752931', + }); + expect(isContentType(headers, 'multipart/form-data')).toBe(true); + }); + }); });