Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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() {
var path = window.location || '/path/to/page'
if (!can.route(path)) {
// 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,367 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.