Skip to content

Instantly share code, notes, and snippets.

@Kequc
Last active September 24, 2015 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kequc/132a0fefa707f6b12d36 to your computer and use it in GitHub Desktop.
Save Kequc/132a0fefa707f6b12d36 to your computer and use it in GitHub Desktop.
Find da memory leak
// `domains` is a global containing valid domains grouped by keys
// this module is instantiated via require at the top of some file and
// the following is run once per request:
// Origin.foundKey(blah, blah);
// some origin stuff
var _ = require('underscore');
module.exports = {
list: function (arr) {
var result = [];
_.each(arr || [], function (domain) {
result.push('http://' + domain);
result.push('https://' + domain);
result.push('http://www.' + domain);
result.push('https://www.' + domain);
});
return result;
},
foundKey: function (key, origin) {
return _.contains(this.list(domains[key]), origin);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment