Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hash-brown-router

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hash-brown-router - npm Package Compare versions

Comparing version 1.3.2 to 1.3.3

32

hash-location.js
var EventEmitter = require('events').EventEmitter
module.exports = function HashLocation() {
module.exports = function HashLocation(window) {
var emitter = new EventEmitter()
var last = ''
function onHashChange() {
emitter.emit('hashchange')
}
window.addEventListener('hashchange', function() {
if (last !== emitter.get()) {
last = emitter.get()
emitter.emit('hashchange')
}
})
window.addEventListener('hashchange', onHashChange)
emitter.go = go.bind(null, window)
emitter.replace = replace.bind(null, window)
emitter.get = get.bind(null, window)
emitter.go = go
emitter.replace = replace
emitter.get = get
return emitter
}
function replace(newPath) {
location.replace(location.origin + location.pathname + '#' + newPath)
function replace(window, newPath) {
window.location.replace(window.location.origin + window.location.pathname + '#' + newPath)
}
function go(newPath) {
location.hash = newPath
function go(window, newPath) {
window.location.hash = newPath
}
function get() {
return removeHashFromPath(location.hash)
function get(window) {
return removeHashFromPath(window.location.hash)
}

@@ -30,0 +32,0 @@

@@ -9,3 +9,3 @@ var pathToRegexp = require('path-to-regexp-with-reversible-keys')

if (!hashLocation) {
hashLocation = browserHashLocation()
hashLocation = browserHashLocation(window)
}

@@ -12,0 +12,0 @@

{
"name": "hash-brown-router",
"version": "1.3.2",
"version": "1.3.3",
"description": "A client-side router that only cares about the bits after the #",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -36,2 +36,8 @@ # hash-brown-router

## `go(newPath)` - navigate to a new path
router.go('/some-other/path')
Changes the current location hash.
## `replace(newPath)` - replace the current route in the browser history

@@ -45,3 +51,3 @@

Convenience method for `location.replace(location.origin + location.pathname + '#' + newPath)`.
Changes the current location hash, replacing the last location in the browser history, i.e. `location.replace(location.origin + location.pathname + '#' + newPath)`.

@@ -48,0 +54,0 @@ ## `evaluateCurrent(defaultPath)` - evaluate the current url

@@ -141,3 +141,3 @@ var router = require('../')

tester.add('parmeters include values from querystring', function(t, locationHash, done) {
tester.add('parameters include values from querystring', function(t, locationHash, done) {
t.plan(4)

@@ -144,0 +144,0 @@

@@ -37,3 +37,3 @@ var domready = require('domready')

function start() {
var hashLocation = browserHashLocation()
var hashLocation = browserHashLocation(window)
allTests.forEach(function(next) {

@@ -40,0 +40,0 @@ test(next.description, function(t) {

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