hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
38.82k stars 4.75k forks source link

refactor: backslashes on Windows #5457

Closed stevenjoezhang closed 2 months ago

stevenjoezhang commented 2 months ago

What does it do?

I have noticed that currently on Windows, paths in Hexo are converted frequently. For example, when adding files to the ctx.model('Cache') database, the path separators \ are replaced with /, and later when Assets use these paths, the join function is called, which on Windows, will replace / back with \. This pull request aims to standardize the separator in the cache's _id to match the current operating system's support and to avoid using hardcoded separators (using path.sep instead). It will not change existing functionalities but is intended to improve the uniformity and maintainability of the code.

WIP: pending https://github.com/hexojs/hexo/pull/5385

Screenshots

Pull request tasks

github-actions[bot] commented 2 months ago

How to test

git clone -b windows https://github.com/hexojs/hexo.git
cd hexo
npm install
npm test
github-actions[bot] commented 2 months ago

flamegraph

https://bb91084fbac463671a969ae0e9d7c5ba8b4396f4-14-hexo.surge.sh/flamegraph.html https://bb91084fbac463671a969ae0e9d7c5ba8b4396f4-16-hexo.surge.sh/flamegraph.html https://bb91084fbac463671a969ae0e9d7c5ba8b4396f4-18-hexo.surge.sh/flamegraph.html

stevenjoezhang commented 2 months ago

See also https://github.com/hexojs/hexo-util/pull/230