Skip to content
Myr

parseCookie() now returns empty hash when cookie is not set

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parent 9532e7f · Browse files · 1 file+11 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+11 added−0 removed

  • other:+11 added−0 removed

1 file+11 added−0 removed

modified:lib/express.core.js+11 added
24 unmodified lines
25 26 start : function(port) {27 this.server.listen(port || 3000, function(request, response){28 request.headers = Express.arrayToHash(request.headers)29 request.cookie = Express.parseCookie(request.headers['Cookie'])30 request.uri.params = Express.parseNestedParams(request.uri.params)31 request.uri.path = Express.normalizePath(request.uri.path)32 Express.request = request33 Express.response.body = Express.callRouteFor(request)
127 unmodified lines
161 162 return params163 },164 165 /**166 * Parse _cookie_ string into an object (hash).167 *168 * @param {string} cookie169 * @return {hash}170 * @api public171 */172 173 parseCookie : function(cookie) {174 var hash = {}175 if (!cookie) return hash176 var attrs = cookie.split(/\s*;\s*/)177 for (i = 0; i < attrs.length; ++i)178 hash[attrs[i].split('=')[0]] = unescape(attrs[i].split('=')[1])179 return hash
239 unmodified lines
419 p(request.headers['User-Agent'])420 p(request.headers['Accept'])421 p(request.headers['Accept-Encoding'])422 p(request.headers['Cookie'])423 p(request.cookie)424 return param('operation') + 'ing ' + param('name')425})426427get('articles', function(){
12 unmodified lines