Skip to content

Commit 5b036c5

Browse files
committed
Changed this.idx initialization (PR salesforce#283) (lib/memstore.js)
1 parent 7c1fdf1 commit 5b036c5

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

lib/memstore.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var util = require('util');
3636

3737
function MemoryCookieStore() {
3838
Store.call(this);
39-
this.idx = {};
39+
this.idx = Object.create(null);
4040
}
4141
util.inherits(MemoryCookieStore, Store);
4242
exports.MemoryCookieStore = MemoryCookieStore;
@@ -86,18 +86,18 @@ MemoryCookieStore.prototype.findCookies = function(domain, path, cb) {
8686

8787
} else {
8888
pathMatcher = function matchRFC(domainIndex) {
89-
//NOTE: we should use path-match algorithm from S5.1.4 here
90-
//(see : https://github.com/ChromiumWebApps/chromium/blob/b3d3b4da8bb94c1b2e061600df106d590fda3620/net/cookies/canonical_cookie.cc#L299)
91-
Object.keys(domainIndex).forEach(function (cookiePath) {
92-
if (pathMatch(path, cookiePath)) {
93-
var pathIndex = domainIndex[cookiePath];
94-
95-
for (var key in pathIndex) {
96-
results.push(pathIndex[key]);
97-
}
98-
}
99-
});
100-
};
89+
//NOTE: we should use path-match algorithm from S5.1.4 here
90+
//(see : https://github.com/ChromiumWebApps/chromium/blob/b3d3b4da8bb94c1b2e061600df106d590fda3620/net/cookies/canonical_cookie.cc#L299)
91+
Object.keys(domainIndex).forEach(function (cookiePath) {
92+
if (pathMatch(path, cookiePath)) {
93+
var pathIndex = domainIndex[cookiePath];
94+
95+
for (var key in pathIndex) {
96+
results.push(pathIndex[key]);
97+
}
98+
}
99+
});
100+
};
101101
}
102102

103103
var domains = permuteDomain(domain) || [domain];
@@ -115,10 +115,10 @@ MemoryCookieStore.prototype.findCookies = function(domain, path, cb) {
115115

116116
MemoryCookieStore.prototype.putCookie = function(cookie, cb) {
117117
if (!this.idx[cookie.domain]) {
118-
this.idx[cookie.domain] = {};
118+
this.idx[cookie.domain] = Object.create(null);
119119
}
120120
if (!this.idx[cookie.domain][cookie.path]) {
121-
this.idx[cookie.domain][cookie.path] = {};
121+
this.idx[cookie.domain][cookie.path] = Object.create(null);
122122
}
123123
this.idx[cookie.domain][cookie.path][cookie.key] = cookie;
124124
cb(null);
@@ -150,7 +150,7 @@ MemoryCookieStore.prototype.removeCookies = function(domain, path, cb) {
150150
};
151151

152152
MemoryCookieStore.prototype.removeAllCookies = function(cb) {
153-
this.idx = {};
153+
this.idx = Object.create(null);
154154
return cb(null);
155155
}
156156

0 commit comments

Comments
 (0)