Skip to content

link & router using "window.location.origin": IE11 incompatible #1120

@eezing

Description

@eezing

References to window.location.origin found in two places. window.location.origin doesn't exists in IE11.

This in link:

export function isLocal (href) {
  const origin = window.location.origin
  return !/^(https?:)?\/\//.test(href) ||
    origin === href.substr(0, origin.length)
}

This in router:

function getURL () {
  const { href, origin } = window.location
  return href.substring(origin.length)
}

IE11 compatible replacement:

const origin = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port: '')

We can either polyfill window.location.origin (not a huge fan of polyfills) or replace the line in both chunks.

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