From a640450fe0c2d32ae43fa7089868798e5d9fb981 Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Tue, 9 Apr 2024 20:46:58 +0800 Subject: [PATCH] fix unit test --- lib/plugins/tag/include_code.ts | 2 +- test/scripts/tags/include_code.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/plugins/tag/include_code.ts b/lib/plugins/tag/include_code.ts index fb6322f5e9..cc059bb1f2 100644 --- a/lib/plugins/tag/include_code.ts +++ b/lib/plugins/tag/include_code.ts @@ -47,7 +47,7 @@ export = (ctx: Hexo) => function includeCodeTag(args: string[]) { // If the language is not defined, use file extension instead lang = lang || extname(path).substring(1); - const source = join(codeDir, path); + const source = join(codeDir, path).replace(/\\/g, '/'); // Prevent path traversal: https://github.com/hexojs/hexo/issues/5250 const Page = ctx.model('Page'); diff --git a/test/scripts/tags/include_code.ts b/test/scripts/tags/include_code.ts index 7d104fbf80..bbbb37e7fd 100644 --- a/test/scripts/tags/include_code.ts +++ b/test/scripts/tags/include_code.ts @@ -99,7 +99,7 @@ describe('include_code', () => { it('to', async () => { const fixture = [ - 'if (tired && night){', + 'if (tired && night) {', ' sleep();' ].join('\n'); const expected = highlight(fixture, { @@ -177,7 +177,7 @@ describe('include_code', () => { it('to', async () => { const fixture = [ - 'if (tired && night){', + 'if (tired && night) {', ' sleep();' ].join('\n'); const expected = prismHighlight(fixture, {