Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(perf): refactor the content-type check from startsWith("text/html") to === "text/html" #85

Merged
merged 3 commits into from
Nov 5, 2024

Conversation

JakeChampion
Copy link
Contributor

"text/html" should be the only value that we act against as that is the only entry in the IANA text type registry which indicates HTML content (https://www.iana.org/assignments/media-types/media-types.xhtml#text).

Also, the HTTP header/field values can not begin or end with whitespace (https://www.rfc-editor.org/rfc/rfc9110.html#section-5.5), which is why we can use a strict equality against the exact string "text/html".

…to `=== "text/html"

`"text/html"` should be the only value that we act against as that is the only entry in the IANA text type registry which indicates HTML content (https://www.iana.org/assignments/media-types/media-types.xhtml#text).

Also, the HTTP header/field values can not begin or end with whitespace (https://www.rfc-editor.org/rfc/rfc9110.html#section-5.5), which is why we can use a strict equality against the exact string "text/html".
Copy link

netlify bot commented Nov 4, 2024

Deploy Preview for csp-nonce ready!

Name Link
🔨 Latest commit c35a66a
🔍 Latest deploy log https://app.netlify.com/sites/csp-nonce/deploys/672a213276fe9e000804c2fd
😎 Deploy Preview https://deploy-preview-85--csp-nonce.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@JakeChampion JakeChampion changed the title perf: refactor the content-type check from startsWith("text/html") to `=== "text/html" fix(perf): refactor the content-type check from startsWith("text/html") to `=== "text/html" Nov 4, 2024
@JakeChampion JakeChampion changed the title fix(perf): refactor the content-type check from startsWith("text/html") to `=== "text/html" fix(perf): refactor the content-type check from startsWith("text/html") to === "text/html" Nov 4, 2024
@JakeChampion JakeChampion merged commit 6aeef74 into main Nov 5, 2024
5 checks passed
@JakeChampion JakeChampion deleted the jake/content-type-check branch November 5, 2024 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants