Closed EmmetZC closed 4 years ago
Thanks for opening this issue, maintainers will get back to you as soon as possible!
Please upgrade to Hexo@4 https://github.com/hexojs/hexo/releases/tag/4.0.0 Currently you're using hexo@3.9.0 which does not encode URLs by default
GitHubA fast, simple & powerful blog framework, powered by Node.js. - hexojs/hexo
Please upgrade to Hexo@4 https://github.com/hexojs/hexo/releases/tag/4.0.0 Currently you're using hexo@3.9.0 which does not encode URLs by default
GitHubhexojs/hexoA fast, simple & powerful blog framework, powered by Node.js. - hexojs/hexo
Upgraded to Hexo@4.2.0 and still not working.
Hexo@4 encodes url by default for sure, but character &
requires encodeURIComponent()
to be encoded properly.
I guess it might be a bad idea to use &
in the post path.
GitHubA fast, simple & powerful blog framework, powered by Node.js. - hexojs/hexo
Hexo doesn't seem to recommend using special symbols in post titles: https://github.com/hexojs/hexo/issues/4104
Anyway, I pushed the bugfix using encodeURIComponent
to the master branch, you can update and try if this issue is solved. Hexo 4 is not backward compatible with URL encode changes, which makes these encode / decode problems tricky
Yeah, right. Apologies for making this problem. Better not use special characters again in the future.I've tried the latest NexT theme and it works fine.Many thanks for your help.
On Sun, Mar 8, 2020 4:42 AM, Mimi notifications@github.com wrote: Hexo doesn't seem to recommend using special symbols in post titles: hexojs/hexo#4104 Anyway, I pushed the bugfix using encodeURIComponent to the master branch, you can update and try if this issue is solved. Hexo 4 is not backward compatible with URL encode changes, which makes these encode / decode problems tricky
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Best Wishes
(Chi Zhang)张驰 +86 13279345523 西安交通大学 电信学院 Xi'an Jiaotong University The School of Electronic and Information Engineering
If you delete this template, we may close your issue without conducting an investigation. 如果您删除此模版,我们可能会在不进行调查的情况下关闭您的 Issue。
Please check if your Issue fulfills the following requirements. This will guide you to resolve the issue quickly. 请务必确认您在提交此 Issue 前已经查看并完成了下列检查单中的所有事项。这会指导您快速地解决问题。
Issue Checklist
Expected behavior
Get post visit count from leancloud
Actual behavior
Links to demo site with this issue: https://emmetzc.github.io/2019/07/16/Diary&Dairy/
Links to repository or source code of the blog: https://github.com/EmmetZC/EmmetZC.github.io/blob/89b8bb24efdf5e3b0741fbe47b69fa288b7ba6c8/2019/07/16/Diary%26Dairy/index.html#L404 In fact, I've fixed this issue by wrapping
JSON.stringify({ url })
intoencodeURIComponent()
, so you won't acturally see it. But I'm pretty sure that this problem happens because the template doesn't handle special characters, such as&
in my example, properly. Patch I used to fix this problem:Counter('get',
/classes/Counter?where=${JSON.stringify({ url })}
)Counter('get',
/classes/Counter?where=${encodeURIComponent(JSON.stringify({ url }))}
) .then(response => response.json()) .then(({ results }) => { if (results.length > 0) { @@ -55,7 +55,7 @@ return decodeURI(element.getAttribute('id')); });Counter('get',
/classes/Counter?where=${JSON.stringify({ url: { '$in': entries } })}
)Counter('get',
/classes/Counter?where=${encodeURIComponent(JSON.stringify({ url: { '$in': entries } }))}
) .then(response => response.json()) .then(({ results }) => { if (results.length === 0) {Steps to reproduce the behavior
&
in its urllocalhost
testing, you may need to deploy it to reproduce the problem.By the way, the post produces this problem was written long ago, and it worked fine back then. That time I was using NeXT theme v7.2.0. Earlier today, I upgraded NeXT to the latest version and this problem newly appeared.
Environment Information
Node.js and NPM Information
Package dependencies Information
Hexo Configuration
NexT Configuration
Other Information