hexo
hexo copied to clipboard
fix: create post with a path composed of numbers throw an error
What does it do?
fix #4334
Screenshots
Pull request tasks
- [x] Add test cases for the changes.
- [x] Passed the CI test.
How to test
git clone -b fix_4334 https://github.com/D-Sketon/hexo.git
cd hexo
npm install
npm test
Coverage increased (+0.04%) to 98.778% when pulling 2ec86827f58b8d4ab22634be998b42bfbd3e0478 on D-Sketon:fix_4334 into 58a8f8c4147782f6d8719abb00cfd91323688ec1 on hexojs:master.
There will be an edge case: --path 0x100
will become string '256'
, not '0x100'
.
You can try to change the code here: https://github.com/hexojs/hexo-cli/blob/5c5fc8fe2fc781a557a30f1bf2043502825f173c/lib/hexo.ts#L18
minimist(process.argv.slice(2), { string: ['_', 'p', 'path'] })
should work
See also https://github.com/hexojs/hexo-cli/pull/200
@stevenjoezhang should slug
also be added to this code?
For example: hexo new page --slug 0x404
will generate 1028.md
@D-Sketon Yes, the slug should also have a string type
You can add other test cases like https://github.com/hexojs/hexo/pull/4363
@stevenjoezhang I'm a bit confused, do I just need to add extra test cases in this PR?
I have tried to add test cases like #4363, but they all fail. It seems that the tests all skip hexo-cli
by using lib\plugins\console\new.js
directly
It's tricky to cover this situation with unit tests, need to hook process.argv
somehow
Superseded by #5465