sandy98 / node-simple-router

Yet another minimalistic router for node.js
node-simple-router.herokuapp.com
MIT License
36 stars 18 forks source link

Email address in URL #30

Open Dam-Buty opened 7 years ago

Dam-Buty commented 7 years ago

First of all, thanks for node-simple-router, it is my GOTO router whenever i need to spin up a quick node API server. The minimalist community thanks you dearly :D

I've recently come to a project where i can possibly have an email address in a part of the URL : http://someserver.co/endpoint/test@gmail.com/action . Unfortunately this is not allowed by the default regex in router.coffee.

After a bit of fiddling around in the code, i found that regex is actually exposed as an option, so i just initialized my router with :

const router = new Router({
  regex: "/([A-Za-z0-9_\\-\\.@]+)"
})

Nothing ground-breaking but i figured it might be worthwhile to either change the default regex (although there might be some unintended side-effects - i'll let you be the judge of that), or at the very least document regex in the README. I am more than willing to propose a PR depending on what choice you land on.

Cheers, DAM