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

director

Package Overview
Dependencies
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

director - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

7

lib/director/browser.js

@@ -224,7 +224,2 @@

Router.prototype.getState = function () {
return this.state;
};
Router.prototype.getRoute = function (v) {

@@ -250,2 +245,2 @@ var ret = v;

return this;
};
};

9

lib/director/http/index.js

@@ -31,2 +31,3 @@ var events = require('events'),

this.recurse = 'forward';
this._attach = [];

@@ -69,3 +70,3 @@ this.extend(exports.methods.concat(['before', 'after']));

Router.prototype.attach = function (func) {
this._attach = func;
this._attach.push(func);
};

@@ -87,3 +88,3 @@

var method = req.method === 'HEAD' ? 'get' : req.method.toLowerCase(),
url = req.url.split('?', 1)[0],
url = decodeURI(req.url.split('?', 1)[0]),
fns = this.traverse(method, url, this.routes, ''),

@@ -97,3 +98,5 @@ thisArg = { req: req, res: res },

if (this._attach) {
this._attach.call(thisArg);
for (var i in this._attach) {
this._attach[i].call(thisArg);
}
}

@@ -100,0 +103,0 @@

@@ -16,4 +16,7 @@ //

exports.BadRequest = function (msg) {
msg = msg || 'Bad request';
this.status = 400;
this.headers = {};
this.message = msg;
this.body = { error: msg };

@@ -25,5 +28,8 @@ };

exports.NotAuthorized = function (msg) {
msg = msg || 'Not Authorized';
this.status = 401;
this.headers = {};
this.body = { error: msg || 'Not Authorized' };
this.message = msg;
this.body = { error: msg };
};

@@ -34,5 +40,8 @@

exports.Forbidden = function (msg) {
msg = msg || 'Not Authorized';
this.status = 403;
this.headers = {};
this.body = { error: msg || 'Not Authorized' };
this.message = msg;
this.body = { error: msg };
};

@@ -43,4 +52,7 @@

exports.NotFound = function (msg) {
msg = msg || 'Not Found';
this.status = 404;
this.headers = {};
this.message = msg;
this.body = { error: msg };

@@ -52,5 +64,8 @@ };

exports.MethodNotAllowed = function (allowed) {
var msg = 'method not allowed.';
this.status = 405;
this.headers = { allow: allowed };
this.body = { error: 'method not allowed.' };
this.message = msg;
this.body = { error: msg };
};

@@ -61,6 +76,9 @@

exports.NotAcceptable = function (accept) {
var msg = 'cannot generate "' + accept + '" response';
this.status = 406;
this.headers = {};
this.message = msg;
this.body = {
error: 'cannot generate "' + accept + '" response',
error: msg,
only: 'application/json'

@@ -73,4 +91,7 @@ };

exports.NotImplemented = function (msg) {
msg = msg || 'Not Implemented';
this.status = 501;
this.headers = {};
this.message = msg;
this.body = { error: msg };

@@ -77,0 +98,0 @@ };

@@ -651,2 +651,5 @@ /*

path = path || [];
if (!Array.isArray(path)) {
path = path.split(self.delimiter);
}

@@ -653,0 +656,0 @@ function insertOrMount(route, local) {

{
"name": "director",
"description": "A client Side/Server Side Router",
"author": "Nodejitsu Inc <info@nodejitsu.com>",
"version": "1.0.10",
"maintainers": [ "hij1nx <hij1nx@me.com>", "indexzero <charlie.robbins@gmail.com>" ],
"contributors": [
{ "name": "Paolo Fragomeni", "email": "hij1nx@nodejitsu.com" },
{ "name": "Charlie Robbins", "email": "charlie@nodejitsu.com" },
{ "name": "Dave Geddes", "email": "davidcgeddes@gmail.com" }
"author": "Nodejitsu Inc. <info@nodejitsu.com>",
"version": "1.0.11",
"maintainers": [
"hij1nx <paolo@nodejitsu.com>",
"indexzero <charlie@nodejitsu.com>"
],

@@ -16,3 +14,11 @@ "repository": {

},
"keywords": ["URL", "router", "http", "cli", "flatiron", "client side"],
"keywords": [
"URL",
"router",
"http",
"cli",
"flatiron",
"client side",
"ender"
],
"devDependencies": {

@@ -27,3 +33,5 @@ "codesurgeon": "0.2.x",

"main": "./lib/director",
"engines": { "node": ">= 0.4.0" },
"engines": {
"node": ">= 0.4.0"
},
"scripts": {

@@ -30,0 +38,0 @@ "test": "vows test/server/*/*-test.js --spec"

@@ -36,26 +36,33 @@ <img src="https://github.com/flatiron/director/raw/master/img/director.png" />

```html
<!html>
<html>
<head>
<script src="/director.js"></script>
<script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>A Gentle Introduction</title>
<script src="https://raw.github.com/flatiron/director/master/build/director-1.0.7.min.js"></script>
<script>
var author = function () { /* ... */ },
books = function () { /* ... */ },
viewBook = function(bookId) { /* bookId is populated. */ };
var author = function () { console.log("author"); },
books = function () { console.log("books"); },
viewBook = function(bookId) { console.log("viewBook: bookId is populated: " + bookId); };
var routes = {
'/author': author,
'/books': [books, function() { /* An inline route handler. */ }],
'/books/view/:bookId': viewBook
};
var routes = {
'/author': author,
'/books': [books, function() { console.log("An inline route handler."); }],
'/books/view/:bookId': viewBook
};
var router = Router(routes);
router.init();
var router = Router(routes);
router.init();
</script>
</head>
<body>
</body>
</html>
</script>
</head>
<body>
<ul>
<li><a href="#/author">#/author</a></li>
<li><a href="#/books">#/books</a></li>
<li><a href="#/books/view/1">#/books/view/1</a></li>
</ul>
</body>
</html>
```

@@ -66,48 +73,59 @@

```html
<!html>
<html>
<head>
<script src="/director.js"></script>
<script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>A Gentle Introduction 2</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="https://raw.github.com/flatiron/director/master/build/director-1.0.7.min.js"></script>
<script>
$('document').ready(function(){
//
// create some functions to be executed when
// the correct route is issued by the user.
//
var showAuthorInfo = function () { console.log("showAuthorInfo"); },
listBooks = function () { console.log("listBooks"); },
allroutes = function() {
var route = window.location.hash.slice(2),
sections = $('section'),
section;
if ((section = sections.filter('[data-route=' + route + ']')).length) {
sections.hide(250);
section.show(250);
}
};
//
// create some functions to be executed when
// the correct route is issued by the user.
//
var author = function () { /* ... */ },
books = function () { /* ... */ },
allroutes = function(route) {
var sections = $('section');
sections.hide();
sections.find('data-route[' + route + ']').show();
};
//
// define the routing table.
//
var routes = {
'/author': showAuthorInfo,
'/books': listBooks
};
//
// define the routing table.
//
var routes = {
'/author': showAuthorInfo,
'/books': [showAuthorInfo, listBooks]
};
//
// instantiate the router.
//
var router = Router(routes);
//
// instantiate the router.
//
var router = Router(routes);
//
// a global configuration setting.
//
router.configure({
on: allroutes
});
router.init();
</script>
</head>
<body>
<section data-route="author">Author Name</section>
<section data-route="books">Book1, Book2, Book3</section>
</body>
</html>
//
// a global configuration setting.
//
router.configure({
on: allroutes
});
router.init();
});
</script>
</head>
<body>
<section data-route="author">Author Name</section>
<section data-route="books">Book1, Book2, Book3</section>
<ul>
<li><a href="#/author">#/author</a></li>
<li><a href="#/books">#/books</a></li>
</ul>
</body>
</html>
```

@@ -738,3 +756,5 @@

### init()
### init([redirect])
* `redirect` {String}: This value will be used if '/#/' is not found in the URL. (e.g., init('/') will resolve to '/#/', init('foo') will resolve to '/#foo').
Initialize the router, start listening for changes to the URL.

@@ -786,2 +806,2 @@

[2]: http://github.com/flatiron/flatiron
[3]: http://github.com/flatiron/union
[3]: http://github.com/flatiron/union
/*
* mount-test.js: Tests for mounting and normalizing routes into a Router instance.
* mount-test.js: Tests for mounting and normalizing routes into a Router instance.
*

@@ -8,3 +8,3 @@ * (C) 2011, Nodejitsu Inc.

*/
var assert = require('assert'),

@@ -63,3 +63,3 @@ vows = require('vows'),

});
assertRoute(root, ['on'], router.routes);

@@ -77,2 +77,15 @@ assertRoute(root, ['after'], router.routes);

assertRoute(foodog, ['foo', '([._a-zA-Z0-9-]+)', 'on'], router.routes);
},
"should accept string path": function(router) {
function dogs () { }
router.mount({
'/dogs': {
on: dogs
}
},
'/api');
assertRoute(dogs, ['api', 'dogs', 'on'], router.routes);
}

@@ -92,3 +105,3 @@ }

function countryCityZip () { }
router.mount({

@@ -102,3 +115,3 @@ '/usa/:city/:zip': usaCityZip,

});
assertRoute(usaCityZip, ['usa', '([\\w\\-]+)', '([\\d]{5})', 'on'], router.routes);

@@ -105,0 +118,0 @@ assertRoute(countryCityZip, ['world', '([A-Z][A-Za-z]+)', '([\\w\\-]+)', '([\\d]{5})', 'on'], router.routes);

Sorry, the diff of this file is not supported yet

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