Skip to content

A cross-origin url cannot be redirected to if "externalLinkTarget" is set to "_self" and "routerMode" is set to "history" #1046

Closed
@ustc-zzzz

Description

@ustc-zzzz

Bug Report

Steps to reproduce

Set the options firstly:

window['$docsify'] = {
  routerMode: 'history',
  externalLinkTarget: '_self'
}

Then write a link whose url is from another domain:

Example: [example.com](https://example.com/)

What is current behaviour

If our domain were docsify.now.sh, it would do nothing and pop an error on the debug console:

Uncaught DOMException: Failed to execute 'pushState' on 'History': A history state object with URL 'https://example.com/' cannot be created in a document with origin 'https://docsify.now.sh' and URL 'https://docsify.now.sh/'.
    at https://unpkg.com/[email protected]/lib/docsify.min.js:1:61459

The corresponding source code is here.

What is the expected behaviour

Redirect to https://example.com/ normally.

Other relevant information

  • Bug does still occur when all/other plugins are disabled?

  • Your OS: Linux ZZZ-PC-4 5.4.0-4-amd64 #1 SMP Debian 5.4.19-1 (2020-02-13) x86_64 GNU/Linux

  • Node.js version: v12.14.0

  • npm/yarn version: 6.13.4

  • Browser version: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36

  • Docsify version: 4.10.2

  • Docsify plugins: None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions