mcavage/node-restify — pull request #401 by derhasi (2013-05-17 09:32:49+00:00)
Title: Routes using regex may invalidate other routes

To avoid duplicate method.names for different regexp a different sanitization has to be done.

In my case I've got two get routes

```
server.get("/image", routes.images.getImagesList);
server.get(/^(\/image\/)(.*)/, routes.images.getImage);
```

When setting it up like that, a request to `/image` will land a Resource not found error for `/image`, a request to `/image/1.jpg` works. When switching the order: `/image` does work, but `/image/1.jpg` does not work.

This seems to be due to a line in `server.js`:
```
opts.name = opts.name.replace(/\W/g, '').toLowerCase();
```

This will provide a name `getimage` for both routes.

When changing that line to `opts.name = new Buffer(opts.name).toString('base64');` the problem is solved.