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

[Theme] Specify charset for HTML responses #4512

Merged
merged 2 commits into from
Sep 25, 2024
Merged

Conversation

frandiox
Copy link
Contributor

WHY are these changes introduced?

Fixes #4479 again, after being reopened with a slightly different issue.

I'm unsure why, but it looks like SFR doesn't add the charset encoding when called from development. It seems to be adding it to production sites, however. The legacy CLI was also adding this (not sure if manually or by calling the API in a different way). cc @karreiro do you perhaps have more context on this?

Note: SFR and legacy CLI are not adding the charset encoding to JS / CSS assets so I've not changed that 🤔

WHAT is this pull request doing?

For themes that don't specify <meta charset="utf-8"> in the layout, certain characters are not rendered correctly:

image

This PR adds the proper charset to the contet-type for HTML responses so things are rendered correctly:

image

How to test your changes?

  1. Remove <meta charset="utf-8"> from your layout.
  2. Render ××hey××Пи好 in any section.

Without this PR it won't render correctly.

cc @Shopify/advanced-edits

Copy link
Contributor

Thanks for your contribution!

Depending on what you are working on, you may want to request a review from a Shopify team:

  • Themes: @shopify/advanced-edits
  • UI extensions: @shopify/ui-extensions-cli
    • Checkout UI extensions: @shopify/checkout-ui-extensions-api-stewardship
  • Hydrogen: @shopify/hydrogen
  • Other: @shopify/app-inner-loop

@frandiox
Copy link
Contributor Author

/snapit

Copy link
Contributor

🫰✨ Thanks @frandiox! Your snapshot has been published to npm.

Test the snapshot by intalling your package globally:

pnpm i -g @shopify/[email protected]

After installing, validate the version by running just shopify in your terminal
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

Copy link
Contributor

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
73.1% (+0.02% 🔼)
8408/11502
🟡 Branches
69.61% (+0.03% 🔼)
4100/5890
🟡 Functions 71.87% 2184/3039
🟡 Lines
73.45% (+0.02% 🔼)
7956/10832

Test suite run success

1894 tests passing in 860 suites.

Report generated by 🧪jest coverage report action from dc30dca

Copy link
Contributor

@karreiro karreiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @frandiox!

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.

[Bug]: JS assets no longer work on theme dev on 127.0.0.1 since 3.67.0
3 participants