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

WIP: Allow `publish` handle files with filenames separated by spaces #5476

Open yapinxxx opened 2 months ago

yapinxxx commented 2 months ago

Allow the publish command to handle files with filenames separated by spaces in the _draft folder.

What does it do?

The update enables filenames to include spaces in the _draft folder. However, the source code modifies the original filename(data.slug) and then incorrectly compares it with the filenames in the _draft folder, leading to erroneous results.

github-actions[bot] commented 2 months ago

How to test

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

Flamegraph

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

yapinxxx commented 2 months ago

Would you like to create a test case against your changes?

If you could assist me in creating a test case, I would greatly appreciate it.


Before submitting my change, I experimented with modifications in the node_modules directory to test my idea.

Once I confirmed the concept could work, I directly edited the TypeScript source code.

However, I faced challenges building the project and comparing changes before and after, so I submitted the pull request without a comparison.

Additionally, creating a test case proved difficult due to my limited expertise in front-end development. I struggled with building the project and providing a comparison, making it hard to create the test case on my own.

yapinxxx commented 2 months ago

Would you like to create a test case against your changes?

Hello @SukkaW , Could you please provide me with some guidance on creating tests for my changes? I've already tried using npm test, but I'm not certain if that's what you're referring to.

SukkaW commented 1 month ago

Would you like to create a test case against your changes?

Hello @SukkaW , Could you please provide me with some guidance on creating tests for my changes? I've already tried using npm test, but I'm not certain if that's what you're referring to.

npm test runs tests against the existing test cases to make sure Hexo's existing behaviors do not change (no regression is introduced in your changes).

You are introducing a new behavior (correct handling of the special filename) that doesn't exist in the current version of Hexo.

You will need to add a test case to make sure that Hexo will always handle the special filename properly. So in the future when we run npm test again, we can make sure Hexo will always handle the special filename correctly.