Skip to content
Myr

fix(aws-lambda): treat binary +xml archive media types as binary (#5424)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* fix(aws-lambda): treat binary +xml archive media types as binary * remove the comment

authored by Yusuke Wada · committed by GitHub · parent 52febbc · Browse files · 2 files+11 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+11 added−1 removed

  • tests:+6 added−0 removed
  • other:+5 added−1 removed

2 files+11 added−1 removed

modified:src/adapter/aws-lambda/handler.test.ts+6 added
105 unmodified lines
106 ['application/msword', true],107 ['application/epub+zip', true],108 ['application/ld+json', false],109 ['application/vnd.oasis.opendocument.text', true],110 ['application/vnd.apple.installer+xml', true],111 ['application/vnd.apple.installer+xml; charset=UTF-8', true],112 ['application/vnd.mozilla.xul+xml', true],113 ['APPLICATION/VND.APPLE.INSTALLER+XML', true],114 ['APPLICATION/JSON', false],115 ['TEXT/PLAIN', false],116 ])('Should determine whether %s it is binary', (mimeType: string, expected: boolean) => {117 expect(defaultIsContentTypeBinary(mimeType)).toBe(expected)118 })119})
520 unmodified lines
modified:src/adapter/aws-lambda/handler.ts+5 added-1 removed
666 unmodified lines
667 * @param contentType The content type to check.668 * @returns True if the content type is binary, false otherwise.669 */670export const defaultIsContentTypeBinary = (contentType: string): boolean => {671 if (/^application\/vnd\.(?:apple\.installer|mozilla\.xul)\+xml\s*(?:;|$)/i.test(contentType)) {672 return true673 }674671 return !/^text\/(?:plain|html|css|javascript|csv)|(?:\/|\+)(?:json|xml)\s*(?:;|$)/.test(675 return !/^text\/(?:plain|html|css|javascript|csv)|(?:\/|\+)(?:json|xml)\s*(?:;|$)/i.test(676 contentType677 )678}679
3 unmodified lines