fix: resemble Netlify Production logic for base64 encoding more closely#3631
Conversation
📊 Benchmark resultsComparing with 72927da Package size: 365 MB⬇️ 0.00% decrease vs. 72927da Legend
|
requests without a content-type will be base64-encoded this also applies to HTTP GET
|
|
||
| contentType = contentType.toLowerCase() | ||
|
|
||
| if (contentType.startsWith('text/')) { |
There was a problem hiding this comment.
Any reason why we can't move these to a single condition?
There was a problem hiding this comment.
I like how each of the conditions is its own case, à la "if it's a text, don't encode; if it's another content-type encoded as json or xml, don't encode; here's a set of exceptions we don't encode". Moving them into a single condition would make that grouping harder to see. Can you elaborate on why we should move them into a single condition?
There was a problem hiding this comment.
Personally, I think having 3 termination points when you can have 1 makes it harder to trace and debug. I also don't see how having a single condition makes the grouping harder to see. It's not a big deal though, and I respect the personal preference if you think it adds more clarity.
Co-authored-by: Eduardo Bouças <mail@eduardoboucas.com>
|
Turns out I inadvertently tried to fix this in #3564 😅, this PR should supersede that I think. |
Summary
Fixes #3315
Updates the CLI's decision logic for encoding incoming requests as base64 or not, to better match what Netlify production infrastructure is doing.
For us to review and ship your PR efficiently, please perform the following steps:
passes our tests.
A picture of a cute animal (not mandatory, but encouraged)