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

sheet-router

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sheet-router - npm Package Compare versions

Comparing version 4.0.1 to 4.0.2

9

href.js

@@ -32,6 +32,9 @@ const window = require('global/window')

e.preventDefault()
const href = node.href.replace(/#$/, '')
cb(href)
window.history.pushState({}, null, href)
cb({
pathname: node.pathname,
search: node.search,
href: node.href,
hash: node.hash
})
}
}

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

const pathname = require('pathname-match')
const wayfarer = require('wayfarer')
const assert = require('assert')
/* eslint-disable no-useless-escape */
const protocol = '^(http(s)?(:\/\/))?(www\.)?'
const domain = '[a-zA-Z0-9-_\.]+'
const qs = '[\?].*$'
/* eslint-enable no-useless-escape */
const prefix = new RegExp(protocol + domain)
const normalize = new RegExp('#')
const suffix = new RegExp(qs)
module.exports = sheetRouter

@@ -36,3 +45,3 @@

if (typeof tree[0] === 'string') {
var route = tree[0].replace(/^\//, '')
var route = tree[0].replace(/^[#\/]/, '')
} else {

@@ -88,3 +97,3 @@ var rootArr = tree[0]

} else {
prevRoute = pathname(pathname(route))
prevRoute = pathname(route)
prevCallback = router(prevRoute)

@@ -97,3 +106,3 @@ return prevCallback(arg1, arg2, arg3, arg4, arg5)

// wrap a function in a function so it can be called at a later time
// fn -> null -> fn
// fn -> obj -> (any, any, any, any, any)
function thunkify (cb) {

@@ -106,1 +115,11 @@ return function (params) {

}
// replace everything in a route but the pathname and hash
// TODO(yw): ditch 'suffix' and allow qs routing
// str -> str
function pathname (route) {
return route
.replace(prefix, '')
.replace(suffix, '')
.replace(normalize, '/')
}
{
"name": "sheet-router",
"version": "4.0.1",
"version": "4.0.2",
"description": "Fast, modular client router",

@@ -25,3 +25,2 @@ "main": "index.js",

"global": "^4.3.0",
"pathname-match": "^1.1.2",
"wayfarer": "^6.2.1",

@@ -28,0 +27,0 @@ "xtend": "^4.0.1"

@@ -42,8 +42,10 @@ const noop = require('noop2')

t.test('should clean urls before matching', function (t) {
t.plan(1)
t.plan(2)
const router = sheetRouter([
['/foo', (params) => t.pass('called')]
['/foo', (params) => t.pass('cleaned qs')],
['#hello-world', (params) => t.pass('matched hash')]
])
router('https://foobar.com/foo#hello-world?bar=baz')
router('https://foobar.com/foo?bar=baz')
router('https://foobar.com#hello-world?bar=baz')
})

@@ -169,1 +171,26 @@

})
test('hash routes', (t) => {
t.test('should allow for hash routes', (t) => {
t.plan(2)
const router = sheetRouter([
['/foo', () => t.pass('foo called'), [
['#bar', () => t.pass('bar called')]
]]
])
router('/foo')
router('/foo#bar')
})
t.test('should allow for hash partials', (t) => {
t.plan(1)
const router = sheetRouter([
['/foo', () => t.pass('foo called'), [
['#:bar', (params) => t.equal(params.bar, 'bar', 'params match')]
]]
])
router('/foo#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