@zambezi/address
Advanced tools
Comparing version 3.0.0 to 3.0.1-replace-state.0
@@ -783,3 +783,2 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
if(zapp.isRoot(node)) location.pushState(uri) | ||
if(resourceWillChange(req, res, node)) dispatchEvent(node, 'resourcewillchange') | ||
@@ -945,3 +944,3 @@ dispatchEvent(node, 'update', {detail : { from : zapp.resource(node), to : uri }}) | ||
, setState: setState | ||
, pushState: pushState | ||
, pushState: deprecatedPushState | ||
, openNewWindow: openNewWindow | ||
@@ -968,8 +967,8 @@ , basePath: basePath | ||
function pushState(path) { | ||
if (~path.indexOf('#/')) { | ||
path = '/' + trimSlashes(path.split('#/')[1]) | ||
} | ||
function trimPath(path) { | ||
return '/' + trimSlashes(~path.indexOf('#/')? path.split('#/')[1] : path) | ||
} | ||
path = unbase(path) | ||
function updateState(path, method) { | ||
path = unbase(trimPath(path)) | ||
@@ -979,3 +978,3 @@ if (path === getState()) { | ||
} else { | ||
history.pushState({ base: base, path: path }, null, rebase(path)) | ||
method({ base: base, path: path }, null, rebase(path)) | ||
return path | ||
@@ -985,2 +984,15 @@ } | ||
function deprecatedPushState(path) { | ||
console.warn('deprecated : location.pushState, to be removed in v.4.0.0.') | ||
return pushState(path) | ||
} | ||
function pushState(path) { | ||
return updateState(path, history.pushState.bind(history)) | ||
} | ||
function replaceState(path) { | ||
return updateState(path, history.replaceState.bind(history)) | ||
} | ||
function openNewWindow(path, target) { | ||
@@ -1101,3 +1113,3 @@ return window.open(rebase(path), target, '') | ||
function trimSlashes(path) { | ||
return (path || '').replace(/^\/+/, '').replace(/\/+$/, '') | ||
return (path || '').replace(/^\/+|\/+$/g, '') | ||
} | ||
@@ -1104,0 +1116,0 @@ }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) |
{ | ||
"name": "@zambezi/address", | ||
"version": "3.0.0", | ||
"version": "3.0.1-replace-state.0", | ||
"description": "API for nap resources", | ||
@@ -5,0 +5,0 @@ "main": "lib/address.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92296
1133
2