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 3.3.1 to 3.4.0

4

changelog.md

@@ -0,1 +1,5 @@

# 3.4.0
- Ignore fake-o hash fragments at the end of the url [#d51d4e42](https://github.com/TehShrike/hash-brown-router/commit/d51d4e42bb42e39643b4750fc3214c663a71fe79)
# 3.3.1

@@ -2,0 +6,0 @@

10

index.js

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

function evaluateCurrentPath(routes, hashLocation, reverse, onNotFound) {
evaluatePath(routes, hashLocation.get(), reverse, onNotFound)
evaluatePath(routes, stripHashFragment(hashLocation.get()), reverse, onNotFound)
}

@@ -95,3 +95,3 @@

function evaluateCurrentPathOrGoToDefault(routes, hashLocation, reverse, onNotFound, defaultPath) {
var currentLocation = hashLocation.get()
var currentLocation = stripHashFragment(hashLocation.get())
var canUseCurrentLocation = currentLocation && (currentLocation !== '/' || defaultPath === '/')

@@ -107,2 +107,8 @@

var urlWithoutHashFragmentRegex = /^([^#]*)(:?#.*)?$/
function stripHashFragment(url) {
var match = url.match(urlWithoutHashFragmentRegex)
return match ? match[1] : ''
}
function isHashLocation(hashLocation) {

@@ -109,0 +115,0 @@ return hashLocation && hashLocation.go && hashLocation.replace && hashLocation.on

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

@@ -31,3 +31,3 @@ "main": "index.js",

"browser-run": "3.5.0",
"browserify": "~11.0.0",
"browserify": "~16.0.0",
"tap-browser-color": "^0.1.2",

@@ -34,0 +34,0 @@ "tape": "~4.1.0",

@@ -476,2 +476,21 @@ var makeRouter = require('../')

})
test('hash fragments are ignored', function(t) {
startTest(function(getRoute) {
var route = getRoute()
route.add('/myroute/:fromUrl', function(parameters) {
t.equal(Object.keys(parameters).length, 2, 'parameters object has two properties')
t.equal(parameters.fromUrl, 'value1', 'Value from the url parameter is correct')
t.equal(parameters.fromQueryString, 'value2', 'Value from the query string is correct')
route.stop()
t.end()
})
locationHash.go('/myroute/value1?fromQueryString=value2#whatever')
})
t.timeoutAfter(4000)
})
}
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