Next.js: link & router using "window.location.origin": IE11 incompatible

Created on 14 Feb 2017  路  2Comments  路  Source: vercel/next.js

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.

Most helpful comment

@arunoda will do

All 2 comments

Okay. That's good.
Send a PR.

Add a common function inside the lib/utils to do this.

@arunoda will do

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sospedra picture sospedra  路  3Comments

rauchg picture rauchg  路  3Comments

wagerfield picture wagerfield  路  3Comments

jesselee34 picture jesselee34  路  3Comments

formula349 picture formula349  路  3Comments