New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rootr

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rootr - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

2

lib/location.js

@@ -50,5 +50,5 @@ 'use strict';

window.addEventListener('popstate', function (event) {
store.redirect(window.location.pathname);
store.redirect(window.location.pathname + window.location.search + window.location.hash);
});
module.exports = store;
{
"name": "rootr",
"version": "0.2.0",
"version": "0.2.1",
"description": "Router for single page app.",

@@ -5,0 +5,0 @@ "repository": {

// mock browser globals
var parseURL = require('url').parse;
var historyQueue = []

@@ -18,12 +19,10 @@

function* goBack() {
var item = historyQueue[historyQueue.length-2]
window.location.pathname = item.path
window.location.search = item.search
windowCallbacks.popstate(item)
historyQueue = historyQueue.slice(0, -1)
// yield 3 times; once for each promise in redirectPath
yield Promise.resolve()
yield Promise.resolve()
yield Promise.resolve()
//console.log(historyQueue.length)
var current = historyQueue.pop()
var previous = historyQueue.pop()
window.location.pathname = previous.pathname
window.location.search = previous.search
window.location.hash = previous.hash
windowCallbacks.popstate(previous)
}

@@ -35,27 +34,9 @@

function parsePath(path) {
var tmp = path.split('?')
let pathname = tmp[0];
let search = tmp[1] || '';
let hash = '';
if (search && search.indexOf('#') > -1){
[search, hash] = search.split('#')
}
search = `?${search}`
hash = `#${hash}`
return {
pathname, search, hash
}
}
global.history = {
pushState: (state, title, path) => {
window.location = parsePath(path)
historyQueue[historyQueue.length-1] = { state, title, path: window.location.pathname, search: window.location.search, hash: window.location.search }
pushState: (state, title, url) => {
window.location = parseURL(url)
historyQueue.push(window.location);
},
replaceState: (state, title, path) => {
window.location = parsePath(path)
replaceState: (state, title, url) => {
window.location = parseURL(url)
},

@@ -157,1 +138,17 @@ }

});
test( 'goBack works correctly', function*(t) {
t.plan(3)
var result = yield location.open('/admin?foo=1#bar')
yield location.open('/admin2')
yield goBack();
var state = location.getState();
t.equal( state.pathname, '/admin')
t.equal( state.search, '?foo=1')
t.equal( state.hash, '#bar')
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc