Skip to content

fix: correct regex for binary types#3564

Closed
Xenonym wants to merge 1 commit into
netlify:mainfrom
Xenonym:fix/binary-types-regex
Closed

fix: correct regex for binary types#3564
Xenonym wants to merge 1 commit into
netlify:mainfrom
Xenonym:fix/binary-types-regex

Conversation

@Xenonym
Copy link
Copy Markdown
Contributor

@Xenonym Xenonym commented Nov 2, 2021

Summary

The regex to match binary MIME types had a typo (applicaton/octet-stream, note the missing i). This PR fixes that by correcting the regex so that application is only spelled once.

This PR also follows the behavior documented in this forum answer where all application/* content types are base64 encoded except for some known text types:

The fix

Going forward, we will base64 encode the body if the content-type starts with application/. This will ensure that binary media types like application/octet-stream and application/pdf arrive at their final destinations intact.

Exceptions

Requests with the following content-types will not be base64 encoded, even though they start with application/:

  • application/json or application/*+json
  • application/xml or application/*+xml
  • application/javascript
  • application/csp-report
  • application/graphql
  • application/x-www-form-urlencoded
  • application/x-ndjson

A picture of a cute animal (not mandatory, but encouraged)
🐫

@erezrokah erezrokah added the type: bug code to address defects in shipped code label Nov 4, 2021
@Xenonym Xenonym changed the title fix: correct and simplify regex for binary types fix: correct regex for binary types Nov 10, 2021
@Xenonym
Copy link
Copy Markdown
Contributor Author

Xenonym commented Nov 17, 2021

Closing in favour of #3631.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug code to address defects in shipped code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants