Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/flash/flashIdCookieProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ CookieIdProvider.prototype.clear = function(req, res, flashId) {

res.headers["Set-Cookie"] = res.headers["Set-Cookie"].filter(function(el) {
return !(new RegExp("^" + flashCookieName + "=").test(el));
});
}) || [];
res.headers["Set-Cookie"].push(clearCookie);
}

return res;
};
};
5 changes: 4 additions & 1 deletion lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ var
UPDATE: httpMethod.PUT,
DESTROY: httpMethod.DELETE
},
LAST_PARAM_DETECTION = /(\/:[\w\d]+)$/,
LAST_PARAM_REPLACEMENT = "?/([^\/\?]*)$",
PATH_PARAMETER_REPLACEMENT = "([^\/\?]+)",
PATH_PARAMETERS = /:([\w\d]+)/g;

Expand Down Expand Up @@ -132,7 +134,8 @@ Router.prototype.route = function(method, path /*, handlers... */) {
paramNames = path.match(PATH_PARAMETERS) || [];
paramNames = paramNames.map(function(x) { return x.substring(1); });

path = new RegExp("^"+path.replace(/\./, '\\.').replace(/\*/g, '(.+)').replace(PATH_PARAMETERS, PATH_PARAMETER_REPLACEMENT)+'$');
path = new RegExp("^"+path.replace(/\./, '\\.').replace(/\*/g, '(.+)').replace(LAST_PARAM_DETECTION, LAST_PARAM_REPLACEMENT).replace(PATH_PARAMETERS, PATH_PARAMETER_REPLACEMENT));
console.log(path);
}

route = makeRoute({ path: path, paramNames: paramNames, apps: apps, originalPath: originalPath });
Expand Down
18 changes: 18 additions & 0 deletions spec/routerSpec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,24 @@ describe 'regex route', ->
expect(res).toBe routeRes
done()

describe 'request with an empty param', ->
res = null
routeRes = null

beforeEach ->
router = bogart.router()
routeRes = bogart.html 'hello'

router.get '/foo/:bar', (req) ->
routeRes

res = router() new MockRequest('/foo')

it 'should still match a variatic route', (done) ->
q.when res, (res) ->
expect(res).toBe routeRes
done()

describe 'request path with encoded slashes', ->
res = null
routeRes = null
Expand Down