Skip to content

Failed to match router path contains encoded string when using permalinks #1946

Closed
@fangbinwei

Description

@fangbinwei
  • I confirm that this is an issue rather than a question.

Bug report

Steps to reproduce

codesandbox link

file tree like below

.
├── 测试
│   └── README.md

I add a nav (/测试) , and I can route to the page successfully.

However, If I set permalink (e.g. /test) to the README.md, vue-router failed to match the page.

What is expected?

vue-router can match the page

What is actually happening?

when setting permalink, the router config generated like below. vue-router failed to match correct page because of the encoded path.

  {
    path: "/%E6%B5%8B%E8%AF%95/index.html",
    redirect: "/test/"
  },

the correct router config should like this

  {
    path: "/测试/index.html",
    redirect: "/test/"
  },

if (regularPath !== pagePath) {
code += `,
{
path: ${JSON.stringify(regularPath)},
redirect: ${JSON.stringify(pagePath)}
}`
}

the problem caused by these codes, regularPath is encoded

Other relevant information

I am trying to generate sidebar/nav automatically, so folder name in Chinese is a useful info to me.

  • Output of npx vuepress info in my VuePress project:
Environment Info:

  System:
    OS: macOS 10.15
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Binaries:
    Node: 11.12.0 - ~/.nvm/versions/node/v11.12.0/bin/node
    Yarn: 1.19.0 - /usr/local/bin/yarn
    npm: 6.7.0 - ~/.nvm/versions/node/v11.12.0/bin/npm
  Browsers:
    Chrome: 77.0.3865.90
    Firefox: Not Found
    Safari: 13.0.2
  npmPackages:
    @vuepress/core:  1.2.0 
    @vuepress/theme-default:  1.2.0 
    vuepress: ^1.0.3 => 1.2.0 
  npmGlobalPackages:
    vuepress: Not Found

Metadata

Metadata

Assignees

No one assigned

    Labels

    has PRHas a related PRtype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions