Skip to content

Commit 4f1983d

Browse files
author
Jon Penwood
committed
Added default color, and fixed issue where apple and google ip were not returning correctly.
1 parent cf98840 commit 4f1983d

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

config/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ module.exports = {
5555
* @type Object
5656
* @optional
5757
*/
58+
defaultColor: 'light-gray',
5859
block: {
5960
component: {
6061
file: './components/maxmind-block.js'

integration.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function doLookup(entities, options, cb) {
6565
}
6666

6767
if (result) {
68-
lookupResults.push(result);
68+
lookupResults.push(cloneDeep(result));
6969
}
7070

7171
next(null);
@@ -148,6 +148,18 @@ function _getCountryCode(cityData) {
148148
return 'O1';
149149
}
150150

151+
const cloneDeep = (entity, cache = new WeakMap()) => {
152+
const referenceTypes = ['Array', 'Object'];
153+
const entityType = Object.prototype.toString.call(entity);
154+
if (!new RegExp(referenceTypes.join('|')).test(entityType)) return entity;
155+
if (cache.has(entity)) {
156+
return cache.get(entity);
157+
}
158+
const c = new entity.constructor();
159+
cache.set(entity, c);
160+
return Object.assign(c, ...Object.keys(entity).map((prop) => ({ [prop]: cloneDeep(entity[prop], cache) })));
161+
};
162+
151163
function _lookupIp(entityObj, countryBlacklist, countryWhitelist, options, cb) {
152164
let cityData = cityLookup.getWithRoutingPrefix(entityObj.value);
153165
let asnData = asnLookup.getWithRoutingPrefix(entityObj.value);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"main": "./integration.js",
33
"name": "MaxMind",
44
"description": "Polarity MaxMind Integration",
5-
"version": "3.2.3-beta",
5+
"version": "3.2.4-beta",
66
"private": true,
77
"dependencies": {
88
"async": "^3.2.0",

0 commit comments

Comments
 (0)