Skip to content

Commit

Permalink
fix api
Browse files Browse the repository at this point in the history
  • Loading branch information
pvorb committed Nov 20, 2011
1 parent f9a75c1 commit 5b34154
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ function Server () {
// 'regularRequest' is emitted, when there are no listeners for the event.
this.addListener('request', function(req, resp) {
var method,
parsed = url.parse(req.url),
path = parsed.pathname;
path;

req.urlParsed = parsed;
req.urlParsed= url.parse(req.url);
path = req.urlParsed.pathname;

if (this.listeners(path).length > 0)
this.emit(path, req, resp);
Expand All @@ -38,7 +38,7 @@ function Server () {
p = method[listener].pattern;

// match it
if ((match = p.exec(path)) != null) {
if ((match = p.exec(req.url)) != null) {
// add to resp
resp.match = match;
// callback
Expand Down Expand Up @@ -72,13 +72,13 @@ Server.prototype.extend = function (method, override) {
this.methods[method] = [];

this[fn] = function (p, cb) {
this.methods[method].push({ pattern: p, callback: cb });
this.methods[method].push({ pattern: Server.util.regExp(p), callback: cb });
};
};

Server.util = {};
Server.util.escPath = function(path) {
return path.replace(/\//g, '\\/');
Server.util.regExp = function(path) {
return new RegExp(path.replace(/\//g, '\\/'));
};

api.Server = Server;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "api",
"description": "A server framework for easy routing",
"tags": [ "server", "middleware", "router" ],
"version": "0.1.0",
"version": "0.1.1",
"repository": {
"type": "git",
"url": "git://github.com/pvorb/node-api.git"
Expand Down

0 comments on commit 5b34154

Please sign in to comment.