Skip to content

Commit

Permalink
change the injector judge
Browse files Browse the repository at this point in the history
  • Loading branch information
mRNA16 committed Nov 15, 2024
1 parent 23669c1 commit b2b8223
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
9 changes: 1 addition & 8 deletions lib/extend/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,7 @@ class Injector {
}

_injector(input: string, pattern: string | RegExp, flag: Entry, isBegin = true, currentType: string): string {
if (
(flag==='head_begin' && /<head.*?>\s*<!-- hexo injector head_begin start -->/.test(input)) ||
(flag==='body_begin' && /<body.*?>\s*<!-- hexo injector body_begin start -->/.test(input)) ||
(flag==='head_end' && /<!-- hexo injector head_end end -->\s*<\/head>/.test(input)) ||
(flag==='body_end' && /<!-- hexo injector body_end end -->\s*<\/body>/.test(input))
) {
return input;
}
if (input.includes(`<!-- hexo injector ${flag}`)) return input;

const code = this.cache.apply(`${flag}-${currentType}-code`, () => {
const content = currentType === 'default' ? this.getText(flag, 'default') : this.getText(flag, currentType) + this.getText(flag, 'default');
Expand Down
1 change: 1 addition & 0 deletions test/scripts/extend/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ describe('Injector', () => {
result.should.contain('<body id="body"><!-- hexo injector body_begin start --><!-- hexo injector body_begin end -->');
result.should.contain('<!-- hexo injector body_end start --><script src="prism.js"></script><!-- hexo injector body_end end --></body>');
});


it('exec() - multi-line head & body', () => {
const content = [
Expand Down

0 comments on commit b2b8223

Please sign in to comment.