Skip to content

Commit

Permalink
allowed @ in URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Demedes committed Jul 31, 2012
1 parent ddbe230 commit 25cb9aa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/route66.coffee
Expand Up @@ -44,7 +44,7 @@ Route66.addRoute = (method, route, functions) -> # generic method for adding rou

Route66.routes[method].push
route: route
regex: new RegExp('^' + route.replace(/\//g, '\\/').replace(/\:([A-Za-z_]+)(\?)?\/?/g, '$2([A-Za-z0-9._-]+)$2') + '\\/?$') # making RegExp from string
regex: new RegExp('^' + route.replace(/\//g, '\\/').replace(/\:([A-Za-z_]+)(\?)?\/?/g, '$2([A-Za-z0-9@._-]+)$2') + '\\/?$') # making RegExp from string
params: params
functions: if functions instanceof Array then functions else toArray(functions).slice 1

Expand Down
2 changes: 1 addition & 1 deletion lib/route66.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "route66",
"version": "0.2.3",
"version": "0.2.4",
"author": "Vadim Demedes <sbioko@gmail.com>",
"description": "Routing functionality/middleware for Connect 2.0",
"main": "./index.js",
Expand Down
12 changes: 10 additions & 2 deletions test/route66.test.coffee
Expand Up @@ -25,6 +25,9 @@ router.post '/', (req, res) ->
router.get '/:first/:second', (req, res) ->
res.end 'Only parameters'

router.get '/:email', (req, res) ->
res.end 'Got an email!'

router.notFound (req, res) ->
res.end "Not found."

Expand Down Expand Up @@ -76,11 +79,16 @@ describe 'Route66', ->
method: 'GET'
, (err, res) ->
res.body.should.equal 'Only parameters'
done()
request
url: 'http://localhost:8080/test@test.com'
method: 'GET'
, (err, res) ->
res.body.should.equal 'Got an email!'
done()

it 'should respond with an error', (done) ->
request
url: 'http://localhost:8080/error'
url: 'http://localhost:8080/one/two/error'
method: 'GET'
, (err, res) ->
res.body.should.equal 'Not found.'
Expand Down

0 comments on commit 25cb9aa

Please sign in to comment.