Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Update to uri-template ~0.3.0

  • Loading branch information...
commit 0aadeff44ca8674085523b08c0b321ba21be05bd 1 parent 9f3075f
Stephen Sugden authored April 06, 2012
18  lib/uri-template-matchpatch.coffee
... ...
@@ -1,5 +1,5 @@
1 1
 # Patch in .match methods to the uri-template Template and Expression prototypes
2  
-{Template, Expression} = require 'uri-template/lib/classes'
  2
+{Template, SimpleExpression} = require 'uri-template/lib/classes'
3 3
 
4 4
 queryStringOps = ['?', '&']
5 5
 
@@ -9,7 +9,7 @@ Template::match = (input) ->
9 9
     input = input.substring m[0].length
10 10
   vars = {}
11 11
   for expr in @expressions
12  
-    inQS = expr.op.first in queryStringOps
  12
+    inQS = expr.first in queryStringOps
13 13
     remaining = expr.match input, vars
14 14
     if remaining is null
15 15
       return false
@@ -27,17 +27,17 @@ Template::match = (input) ->
27 27
 #   * false if the match failed 
28 28
 #   * null if the enclosing template should be forced to fail as well
29 29
 #   * the remaining input if the match succeeds
30  
-Expression::match = (input, vars) ->
  30
+SimpleExpression::match = (input, vars) ->
31 31
   len = 0 # The total length of matched input
32  
-  inQS = @op.first in queryStringOps
  32
+  inQS = @first in queryStringOps
33 33
   if not inQS
34 34
     [input, qs] = input.split '?'
35 35
     qs = if qs then '?'+qs else ''
36 36
   else
37 37
     qs = ''
38 38
 
39  
-  if @op.first
40  
-    return false unless input.substring(0,1) is @op.first
  39
+  if @first
  40
+    return false unless input.substring(0,1) is @first
41 41
     input = input.substring 1
42 42
     len++
43 43
 
@@ -52,8 +52,8 @@ Expression::match = (input, vars) ->
52 52
   i = 0
53 53
   named = {}
54 54
   ordered = []
55  
-  for part in matchable.split @op.sep
56  
-    if part.match(/\//) and @op.allow isnt 'U+R'
  55
+  for part in matchable.split @sep
  56
+    if part.match(/\//) and @allow isnt 'U+R'
57 57
       return null
58 58
     [n, v] = part.split '='
59 59
     if not v?
@@ -74,6 +74,8 @@ Expression::match = (input, vars) ->
74 74
       else
75 75
         v = ordered.shift()
76 76
     return false unless v or inQS
  77
+    v.typeName = p.extensions if p.extensions
77 78
     vars[p.name] = v or []
78 79
   remaining = input.substring len
79 80
   remaining + qs
  81
+
2  package.json
@@ -21,7 +21,7 @@
21 21
   "dependencies": {
22 22
     "coffee-script": "~1.2.0",
23 23
     "connect": "~2.0.0",
24  
-    "uri-template": "~0.2.0"
  24
+    "uri-template": "~0.3.0"
25 25
   },
26 26
   "devDependencies": {
27 27
     "consolidate": "0.1.0",

0 notes on commit 0aadeff

Please sign in to comment.
Something went wrong with that request. Please try again.