Permalink
Browse files

Now parses URL parameters into KVPs

  • Loading branch information...
knowlecules committed Jun 29, 2012
1 parent df191b5 commit 6803c9e65fcfebb89c8bb59c07d6bd3a315c0016
Showing with 9 additions and 1 deletion.
  1. +8 −1 lib/rapid-rest.js
  2. +1 −0 package.json
View
@@ -1,3 +1,10 @@
+/**
+ * Created with JetBrains WebStorm.
+ * User: jrudland
+ * Date: 26/06/12
+ * Time: 11:02 PM
+ * To change this template use File | Settings | File Templates.
+ */
var http = require('http');
var url = require('url');
@@ -84,7 +91,7 @@ module.exports = function() {
var urlDef = url.parse(urlPath, true);
var urlMatch = urlDef.pathname.replace(/[\-[\]\{\}\(\)\*\+\?\.,\/\\\^\$\|#\s]/g, "\\$&").replace(/(:[^(\\/)]+)/g,"([^/]*)");
var patternRE = new RegExp(urlMatch);
- var paramKeys = (urlDef.pathname.indexOf("/:")) ? urlDef.pathname.replace(/(\/[^:][^\/]+)/g, '').substr(2).split("/:") :[];
+ var paramKeys = (urlPath.indexOf("/:") > -1) ? urlPath.replace(/(\/[^:][^\/]+)/g, '').substr(2).split("/:") :[];
var queryKeys = urlDef.query;
location[urlMatch] = rest.handlers({});
View
@@ -1,5 +1,6 @@
{
"name": "rapid-rest",
+ "version": "0.1.1",
"description": "Minimal rest server",
"author": "Jason Rudland <knowlecules@gmail.com>",
"dependencies": {

0 comments on commit 6803c9e

Please sign in to comment.