visionmedia/express-namespace — Issue #11: Strange behavior on Windows
Author: alefnula
Created: 2011-12-06 14:55:54+00:00
State: open

For some strange reason it turns the forward slashes into backward slashes and messes up the regular expressions... For example:

```javascript
app.namespace('/b', function () {
app.get('/:release/', function () {});
}
```

the error I get is:

```
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
SyntaxError: Invalid regular expression: /^\b\(?:([^\/]+?))\\/?$/: Unmatched ')'
at new RegExp (unknown source)
at normalize (D:\workspace\v3\Board@Web\node_modules\express\lib\router\route.js:87:56)
at new Route (D:\workspace\v3\Board@Web\node_modules\express\lib\router\route.js:35:17)
at Router._route (D:\workspace\v3\Board@Web\node_modules\express\lib\router\index.js:389:15)
at HTTPServer. (D:\workspace\v3\Board@Web\node_modules\express\lib\http.js:556:31)
at HTTPServer. (D:\workspace\v3\Board@Web\node_modules\express-namespace\index.js:66:12)
at HTTPServer.namespace (D:\workspace\v3\Board@Web\node_modules\express-namespace\index.js:29:6)
at HTTPServer.get (D:\workspace\v3\Board@Web\node_modules\express-namespace\index.js:58:10)
```

Hackey fix that works for me is:

```javascript
exports.__defineGetter__('currentNamespace', function(){
return join.apply(this, this._ns).replace(/\\/g, '/').replace(/\/$/, '') || '/';
});
```

But it probably brakes something else :)