Skip to content

Algolia search redirects with duplicated base url #1802

Closed
@zowe-robot

Description

@zowe-robot
  • I confirm that this is an issue rather than a question.

Bug report

Steps to reproduce

  • Have Algolia search setup
  • The document website has site config base configured, for example, /docs.
  • Search any keyword and click on a search result
  • The page will try to navigate to a Url with duplicated base url, In the above, example, will be '/docs/docs/path/to/result.html`.

What is expected?

  • The page should navigate to a correct url.
  • Or allow user to configure handleSelected as algolia config to overwrite default build-in behavior.

What is actually happening?

On lines around https://github.com/vuejs/vuepress/blob/master/packages/%40vuepress/theme-default/components/AlgoliaSearchBox.vue#L41

            handleSelected: (input, event, suggestion) => {
              const { pathname, hash } = new URL(suggestion.url)
              this.$router.push(`${pathname}${hash}`)
            }

If the suggestion url is https://my-domain.com/docs/path/to/result.html`, pathname will be /docs/path/to/result.html. When we use $router.push, the $router will also prepend /docs base url to the path which results in double base url.

Also the handleSelected handling overwrites any configurations on site level algolia config of handleSelected.

Other relevant information

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

  System:
    OS: macOS 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
  Binaries:
    Node: 8.11.2 - ~/.nvm/versions/node/v8.11.2/bin/node
    Yarn: 1.10.1 - ~/.nvm/versions/node/v8.11.2/bin/yarn
    npm: 6.4.0 - ~/.nvm/versions/node/v8.11.2/bin/npm
  Browsers:
    Chrome: 76.0.3809.100
    Firefox: 60.8.0
    Safari: 12.1.2
  npmPackages:
    @vuepress/core:  1.0.3 
    @vuepress/theme-default:  1.0.3 
    vuepress: ^1.0.3 => 1.0.3 
  npmGlobalPackages:
    vuepress: Not Found

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: pluginsRelates to VuePress pluginstype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions