Skip to content

Commit

Permalink
Merge commit from fork
Browse files Browse the repository at this point in the history
fixed typo in identifying content type
  • Loading branch information
shairez authored Dec 13, 2024
2 parents 3f9bc67 + 7872974 commit d70d709
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,6 @@ export async function measure<T>(
}

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);
}
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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);
});
});
});

0 comments on commit d70d709

Please sign in to comment.