Skip to content

Incorrect TOC anchor generation #5695

@D-Sketon

Description

@D-Sketon

Check List

  • I have already read Docs page & Troubleshooting page.
  • I have already searched existing issues and they are not help to me.
  • I examined error or warning messages and it's difficult to solve.
  • I am using the latest version of Hexo. (run hexo version to check)
  • My Node.js is matched the required version.

Expected behavior

now
<h2 id="%20[square]">%20[square]</h2>
generate
<a class="toc-link" href="#%20%5Bsquare%5D"></a>

Actual behavior

the anchor is invalid, it should be
<a class="toc-link" href="#%2520%5Bsquare%5D"></a>

I want to know if

const href = id ? `#${encodeURL(id)}` : null;
should be changed to encodeURI.

How to reproduce?

/

Is the problem still there under Safe mode?

/

Your Node.js & npm version


Your Hexo and Plugin version


Your package.json

Your site's _config.yml (Optional)

Others

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions