Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
can-route
Advanced tools
A simple regexp router that runs inside a `http.createServer` handler and returns false when it can’t route a request.
can-route is a simple router that runs inside a http.createServer
handler and returns false when it can’t route a request. Its routes are defined with named regular expressions.
npm install can-route
var http = require('http')
var can = require('can-route')()
// Home
can.get(/^\/$/,
function(req, res) {
res.end('Welcome to the homepage\n')
}
)
// Item
can.patch(/^\/(:<id>[a-f0-9]{16})\/?$/i,
function(req, res, params) {
res.end(params.id + '\n')
}
)
// Server
http.createServer(function(req, res) {
if (!can.route(req, res)) {
res.statusCode = 404
res.end()
}
}).listen(8080)
can-route also works in the browser with basically the same API:
var can = require('can-route')()
can.get(/^\/$/, function() {
// No arguments for routes without parameters.
})
can.get(/^\/(:<name>[a-z]+)\/?$/i, function(params) {
// The only possible argument is the param object.
})
can.get(/#\/(:<name>[a-z]+)\/$/i, function(params) {
// It's possible to define routes based on
// the value of location.hash.
})
window.onpopstate = function() {
if (!can.route(window.location)) {
// Handle 404
}
}
window.onhashchange = function() {
var includeQueryAndHash = true
if (!can.route(window.location, includeQueryAndHash)) {
// Handle 404
}
}
FAQs
Observable front-end application routing for CanJS.
The npm package can-route receives a total of 1,517 weekly downloads. As such, can-route popularity was classified as popular.
We found that can-route demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 16 open source maintainers 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.
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.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.