single-spa
Advanced tools
Comparing version 2.1.3 to 2.1.4
@@ -35,2 +35,4 @@ 'use strict'; | ||
var _singleSpaHelpers = require('./single-spa.helpers.js'); | ||
var window = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : self; | ||
@@ -252,9 +254,18 @@ | ||
var href = window.location.href; | ||
var current = (0, _singleSpaHelpers.parseUri)(window.location.href); | ||
var destination = (0, _singleSpaHelpers.parseUri)(url); | ||
if (url.indexOf('#') > -1 && href.substring(0, href.indexOf('#')) === url.substring(0, url.indexOf('#'))) { | ||
window.location.hash = url.substring(url.indexOf('#')); | ||
if (url.indexOf('#') === 0) { | ||
window.location.hash = '#' + destination.anchor; | ||
} else if (!isSamePath(destination.path, current.path) || current.host !== destination.host && destination.host) { | ||
// different path or a different host | ||
window.history.pushState(null, null, url); | ||
} else { | ||
window.history.pushState(null, null, url); | ||
window.location.hash = '#' + destination.anchor; | ||
} | ||
function isSamePath(destination, current) { | ||
// if the destination has a path but no domain, it doesn't include the root '/' | ||
return current === destination || current === '/' + destination; | ||
} | ||
} | ||
@@ -261,0 +272,0 @@ |
{ | ||
"name": "single-spa", | ||
"version": "2.1.3", | ||
"version": "2.1.4", | ||
"description": "Multiple applications, one page", | ||
@@ -5,0 +5,0 @@ "main": "lib/single-spa.js", |
import { handleChildAppError } from './single-spa-child-app-error.js'; | ||
import { ensureJQuerySupport } from './jquery-support.js'; | ||
import { parseUri } from './single-spa.helpers.js'; | ||
@@ -207,9 +208,18 @@ const window = typeof window !== 'undefined' ? window : (typeof global !== 'undefined' ? global : self); | ||
const href = window.location.href; | ||
const current = parseUri(window.location.href); | ||
const destination = parseUri(url); | ||
if (url.indexOf('#') > -1 && href.substring(0, href.indexOf('#')) === url.substring(0, url.indexOf('#'))) { | ||
window.location.hash = url.substring(url.indexOf('#')); | ||
if (url.indexOf('#') === 0) { | ||
window.location.hash = '#' + destination.anchor; | ||
} else if (!isSamePath(destination.path, current.path) || (current.host !== destination.host && destination.host)) { | ||
// different path or a different host | ||
window.history.pushState(null, null, url); | ||
} else { | ||
window.history.pushState(null, null, url); | ||
window.location.hash = '#' + destination.anchor; | ||
} | ||
function isSamePath(destination, current) { | ||
// if the destination has a path but no domain, it doesn't include the root '/' | ||
return current === destination || current === '/' + destination; | ||
} | ||
} | ||
@@ -216,0 +226,0 @@ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
63882
21
1164
0