vuepress / core

Vue-Powered Static Site Generator
https://vuepress.vuejs.org
MIT License
2.31k stars 923 forks source link

[Bug report] docsearch plugin incorrectly strips base URL out of search results #933

Closed ascott18 closed 2 years ago

ascott18 commented 2 years ago

Description

While this does not break normal left clicks on the link because those are handled with vue-router which does need the truncated URL, this does break all right-click operations (open in new tab, open in new window), and breaks middle-click to open in a new tab.

Reproduction

https://intellitect.github.io/Coalesce

Used Package Manager

npm

System Info

Note: I can't upgrade past beta.43 due to https://github.com/vuepress/vuepress-next/issues/653#issuecomment-1152729495. However, the code that handles this bug is still the same.

System:
    OS: Windows 10 10.0.19044
    CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
    Memory: 6.62 GB / 31.94 GB
  Binaries:
    Node: 16.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.15.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.1.3 - C:\Program Files\nodejs\npm.CMD
  Utilities:
    Git: 2.29.2.
  Browsers:
    Chrome: 101.0.4951.67
    Edge: Spartan (44.19041.1266.0), Chromium (102.0.1245.33)
  npmPackages:
    @vuepress/bundler-vite:  2.0.0-beta.43
    @vuepress/bundler-webpack: Not Found
    @vuepress/cli:  2.0.0-beta.43
    @vuepress/client:  2.0.0-beta.43
    @vuepress/core:  2.0.0-beta.43
    @vuepress/markdown:  2.0.0-beta.43
    @vuepress/plugin-active-header-links:  2.0.0-beta.43
    @vuepress/plugin-back-to-top:  2.0.0-beta.43
    @vuepress/plugin-container:  2.0.0-beta.43
    @vuepress/plugin-docsearch: 2.0.0-beta.43 => 2.0.0-beta.43
    @vuepress/plugin-external-link-icon:  2.0.0-beta.43
    @vuepress/plugin-git:  2.0.0-beta.43
    @vuepress/plugin-google-analytics: Not Found
    @vuepress/plugin-medium-zoom:  2.0.0-beta.43
    @vuepress/plugin-nprogress:  2.0.0-beta.43
    @vuepress/plugin-palette:  2.0.0-beta.43
    @vuepress/plugin-prismjs:  2.0.0-beta.43
    @vuepress/plugin-pwa: Not Found
    @vuepress/plugin-pwa-popup: Not Found
    @vuepress/plugin-register-components: 2.0.0-beta.43 => 2.0.0-beta.43
    @vuepress/plugin-search: Not Found
    @vuepress/plugin-shiki: 2.0.0-beta.43 => 2.0.0-beta.43
    @vuepress/plugin-theme-data:  2.0.0-beta.43
    @vuepress/plugin-toc: Not Found
    @vuepress/shared:  2.0.0-beta.43
    @vuepress/theme-default:  2.0.0-beta.43
    @vuepress/utils:  2.0.0-beta.43
    vue:  3.2.37
    vue-loader: Not Found
    vue-router:  4.0.15
    vuepress: 2.0.0-beta.43 => 2.0.0-beta.43
    vuepress-vite:  2.0.0-beta.43
    vuepress-webpack: Not Found
meteorlxy commented 2 years ago

As I don't have a crawler configured with /base/, I didn't check if the fix is actually valid in practice. It would be helpful if you can help to confirm the fix @ascott18

ascott18 commented 2 years ago

Worked great. Thanks!