mcavage/node-restify — pull request #368 by Aldaviva (2013-04-10 06:29:08+00:00)
Title: Route /\/.*/ does not match request /?

**Steps to reproduce**

1. Set server to use pre-filter `restify.pre.sanitizePath()`
2. Register a route with pattern such as `/\/.*/`
3. Make a request to `/?`
4. Server returns ResourceNotFound instead of using the route

**Root cause**

1. `pre.sanitizePath` converts all sequences of `/?` into `?`, which makes sense for `/foo/?bar=baz`
2. In the case where the request path starts with `/?`, the sanitized path is now just `?`
3. Node's `url.parse` converts `?` into `{ pathname: null, ... }`
4. Restify uses the pathname to match routes, and matching against null would make most legitimate routes fail (and `/null/` would succeed, interestingly)

**Proposed resolution**

* In `pre.sanitizePath`, leave `/?` at the start of a request URL alone, instead of converting to `?`