Skip to content
Browse files

Fixed incompatibility with node 0.6.x.

In 0.4.x typeof regex is 'function', in 0.6.x it's 'object'. So this snippet:

    @get /\/regex$/, 'foo'

Would be incorrectly interpreted as zappa's alternative interface:

    @get {'/key': 'foo'}

Now making the distinction based on the number of arguments instead.
  • Loading branch information...
1 parent 04881f3 commit 24e626c43752e3789bedf0beaeec100b1103c682 @mauricemach mauricemach committed Nov 22, 2011
Showing with 2 additions and 2 deletions.
  1. +1 −1 docs/zappa.html
  2. +1 −1 src/
2 docs/zappa.html
@@ -71,7 +71,7 @@
<span class="k">for</span> <span class="nx">verb</span> <span class="k">in</span> <span class="p">[</span><span class="s1">&#39;get&#39;</span><span class="p">,</span> <span class="s1">&#39;post&#39;</span><span class="p">,</span> <span class="s1">&#39;put&#39;</span><span class="p">,</span> <span class="s1">&#39;del&#39;</span><span class="p">]</span>
<span class="nx">do</span> <span class="nf">(verb) -&gt;</span>
<span class="nx">context</span><span class="p">[</span><span class="nx">verb</span><span class="p">]</span> <span class="o">=</span> <span class="o">-&gt;</span>
- <span class="k">if</span> <span class="k">typeof</span> <span class="nx">arguments</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">isnt</span> <span class="s1">&#39;object&#39;</span>
+ <span class="k">if</span> <span class="nx">arguments</span><span class="p">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="mi">1</span>
<span class="nx">route</span> <span class="nv">verb: </span><span class="nx">verb</span><span class="p">,</span> <span class="nv">path: </span><span class="nx">arguments</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nv">handler: </span><span class="nx">arguments</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
<span class="k">else</span>
<span class="k">for</span> <span class="nx">k</span><span class="p">,</span> <span class="nx">v</span> <span class="k">of</span> <span class="nx">arguments</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
2 src/
@@ -124,7 +124,7 @@ = (func) ->
for verb in ['get', 'post', 'put', 'del']
do (verb) ->
context[verb] = ->
- if typeof arguments[0] isnt 'object'
+ if arguments.length > 1
route verb: verb, path: arguments[0], handler: arguments[1]
for k, v of arguments[0]

0 comments on commit 24e626c

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