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 double quotes inside cloudflare analytics HTML attribute #520

Merged
merged 1 commit into from
May 21, 2022
Merged

Fix double quotes inside cloudflare analytics HTML attribute #520

merged 1 commit into from
May 21, 2022

Conversation

icpz
Copy link
Contributor

@icpz icpz commented May 13, 2022

PR Checklist

  • The commit message follows guidelines for NexT.
  • Tests for the changes was maked (for bug fixes / features).
    • Muse | Mist have been tested.
    • Pisces | Gemini have been tested.
  • Docs in NexT website have been added / updated (for features).

PR Type

  • Bugfix.
  • Feature.
  • Code style update (formatting, local variables).
  • Refactoring (no functional changes, no api changes).
  • Documentation.
  • Translation.
  • Other... Please describe:

What is the current behavior?

I'm using hexo 6.2.0
The origin cloudflare.njk is rendered using single quote, like data-cf-beacon='{"token": "xxx"}'.
But it's somehow replaced to double quote after hexo g, like data-cf-beacon="{"token": "xxx"}", which causes cloudflare analytics malfunction.

What is the new behavior?

Now the double quote inside the attribute is replaced to the HTML entities, to get rid of the single quote replacement.

@welcome
Copy link

welcome bot commented May 13, 2022

Thanks so much for opening your first PR here!

@coveralls
Copy link

Pull Request Test Coverage Report for Build 2318835605

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 94.468%

Totals Coverage Status
Change from base Build 2305723111: 0.0%
Covered Lines: 138
Relevant Lines: 141

💛 - Coveralls

@stevenjoezhang
Copy link
Member

How about switching the single and double quotes in this script element?

@icpz
Copy link
Contributor Author

icpz commented May 14, 2022

Hi @stevenjoezhang, I've tried and it didn't work as single quote string is not valid JSON token. JSON.parse only accepts double quotes strings.

@icpz
Copy link
Contributor Author

icpz commented May 14, 2022

{ 'key': 'value' } is not a valid json string, and will cause an exception while JSON.parse

@stevenjoezhang stevenjoezhang added this to the 8.11.2 milestone May 15, 2022
@stevenjoezhang stevenjoezhang merged commit 296edd3 into next-theme:master May 21, 2022
@welcome
Copy link

welcome bot commented May 21, 2022

Congrats on merging your first pull request here! 🎉 How awesome!

@icpz icpz deleted the fix-cloudflare-analytics-attribute branch May 23, 2022 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants