Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

can-route

Package Overview
Dependencies
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-route - npm Package Compare versions

Comparing version 0.1.3 to 0.2.0

2

package.json
{
"name": "can-route",
"version": "0.1.3",
"version": "0.2.0",
"description": "A simple regexp router that runs inside a `http.createServer` handler and returns false when it can’t route a request.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -61,3 +61,4 @@ # can-route

window.onpopstate = function() {
if (!can.route(window.location)) {
var path = window.location || '/path/to/page'
if (!can.route(path)) {
// Handle 404

@@ -64,0 +65,0 @@ }

@@ -25,3 +25,6 @@ var named = require('named-regexp').named

Can.prototype.route = function(req, res) {
var href = req.url || req.href
var pathname = (typeof req == 'string' ?
req : null
)
var method = (server ?

@@ -32,13 +35,16 @@ req.method.toLowerCase() : 'get'

var hash = !server && res === true
var pathname = null
if (server) {
pathname = url.parse(href).pathname
if (!pathname) {
var href = req.url || req.href
if (server) {
pathname = url.parse(href).pathname
}
else {
pathname = (hash ?
href.substr(href.indexOf(req.pathname)) :
req.pathname
)
}
}
else {
pathname = (hash ?
href.substr(href.indexOf(req.pathname)) :
req.pathname
)
}
var routes = this.routes

@@ -45,0 +51,0 @@ var routeable = false

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