Socket
Socket
Sign inDemoInstall

router

Package Overview
Dependencies
1
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.0 to 0.4.1

9

index.js

@@ -7,3 +7,3 @@ var http = require('http');

var createRouter = function(options) { // TODO: params instead of matches
var createRouter = function(options) {
var that = common.createEmitter();

@@ -13,10 +13,7 @@

// this check may seem a bit confusing. basicly if options is a server or a router
// then just return the attached router
// TODO: maybe listen for # of request handlers on the server to decide whether to autoclose
if (options.router) {
return options.router;
}
// if options if already a server we just sugar it and create a router
// that doesnt autoclose (otherwise we could have really weird rcs)
// TODO: maybe listen for # of request handlers on the server to decide whether to autoclose
if (typeof options.listen === 'function') {

@@ -23,0 +20,0 @@ return createRouter({server:options, autoclose:false});

@@ -34,4 +34,8 @@ module.exports = function(pattern) {

if (map.wildcard) {
map['*'] = map.wildcard;
}
return map;
};
};
{
"name":"router",
"version":"0.4.0",
"version":"0.4.1",
"description":"A lean and mean web router",

@@ -5,0 +5,0 @@ "contributors": [

@@ -7,3 +7,3 @@ # Router

The router routes using the method and a pattern
The router routes using the method and a [.net](http://msdn.microsoft.com/en-us/library/cc668201.aspx) inspired pattern

@@ -45,3 +45,3 @@ ``` js

If you want to just match everything you can use a wildcard `*` which works like unix wildcards.
If you want to just match everything you can use a wildcard `*` which works like unix wildcards

@@ -55,2 +55,10 @@ ``` js

If the standard capture groups aren't expressive enough for you can specify an optional inline regex
``` js
router.get('/{digits}([0-9]+)', function(request, response) {
// matches both '/24' and '/424' but not '/abefest' and so on.
});
```
You can also use regular expressions and the related capture groups instead:

@@ -57,0 +65,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc