Permalink
Browse files

Update to uri-template ~0.3.0

  • Loading branch information...
1 parent 9f3075f commit 0aadeff44ca8674085523b08c0b321ba21be05bd @grncdr grncdr committed Apr 6, 2012
Showing with 11 additions and 9 deletions.
  1. +10 −8 lib/uri-template-matchpatch.coffee
  2. +1 −1 package.json
@@ -1,5 +1,5 @@
# Patch in .match methods to the uri-template Template and Expression prototypes
-{Template, Expression} = require 'uri-template/lib/classes'
+{Template, SimpleExpression} = require 'uri-template/lib/classes'
queryStringOps = ['?', '&']
@@ -9,7 +9,7 @@ Template::match = (input) ->
input = input.substring m[0].length
vars = {}
for expr in @expressions
- inQS = expr.op.first in queryStringOps
+ inQS = expr.first in queryStringOps
remaining = expr.match input, vars
if remaining is null
return false
@@ -27,17 +27,17 @@ Template::match = (input) ->
# * false if the match failed
# * null if the enclosing template should be forced to fail as well
# * the remaining input if the match succeeds
-Expression::match = (input, vars) ->
+SimpleExpression::match = (input, vars) ->
len = 0 # The total length of matched input
- inQS = @op.first in queryStringOps
+ inQS = @first in queryStringOps
if not inQS
[input, qs] = input.split '?'
qs = if qs then '?'+qs else ''
else
qs = ''
- if @op.first
- return false unless input.substring(0,1) is @op.first
+ if @first
+ return false unless input.substring(0,1) is @first
input = input.substring 1
len++
@@ -52,8 +52,8 @@ Expression::match = (input, vars) ->
i = 0
named = {}
ordered = []
- for part in matchable.split @op.sep
- if part.match(/\//) and @op.allow isnt 'U+R'
+ for part in matchable.split @sep
+ if part.match(/\//) and @allow isnt 'U+R'
return null
[n, v] = part.split '='
if not v?
@@ -74,6 +74,8 @@ Expression::match = (input, vars) ->
else
v = ordered.shift()
return false unless v or inQS
+ v.typeName = p.extensions if p.extensions
vars[p.name] = v or []
remaining = input.substring len
remaining + qs
+
View
@@ -21,7 +21,7 @@
"dependencies": {
"coffee-script": "~1.2.0",
"connect": "~2.0.0",
- "uri-template": "~0.2.0"
+ "uri-template": "~0.3.0"
},
"devDependencies": {
"consolidate": "0.1.0",

0 comments on commit 0aadeff

Please sign in to comment.