Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
hash-brown-router
Advanced tools
A router that is only concerned with single-page apps that want to change state based on the bits of the url after the hash.
var makeRouter = require('hash-brown-router')
var router = makeRouter()
add(routeString, cb)
- add routesrouter.add('/page/:pageName', function(parameters) {
console.log(parameters.pageName)
})
Parses express-style route paths, using a fork of path-to-regexp.
setDefault(cb)
- set a default/404 routerouter.setDefault(function(path, parameters) {
console.log("you went to", path, "but that doesn't go anywhere, I guess you just end up here")
})
Called whenever the hash route changes, but no other matching route is found.
replace(newPath)
- replace the current route in the browser historyrouter.add('/page/:pageName', function(parameters) {
if (doesNotExistInTheDatabase(parameters.pageName)) {
router.replace('/pageNotFound')
}
})
Convenience method for location.replace(location.origin + location.pathname + '#' + newPath)
.
evaluate(defaultPath)
- evaluate the current urlForces the library to evaluate the current route from location.hash. Probably best do do once the dom is ready.
router.evaluate('/home')
If location.hash is currently empty, it changes the path to the default path value you pass in.
stop()
If for some reason you want the router to start ignoring hash change events. you can call route.stop()
.
FAQs
A client-side router that only cares about the bits after the #
The npm package hash-brown-router receives a total of 184 weekly downloads. As such, hash-brown-router popularity was classified as not popular.
We found that hash-brown-router demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.