Skip to content

Commit

Permalink
verify that we have a url before third party web tries to get the domain
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore committed Jun 20, 2019
1 parent e641b3c commit c6670af
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions lib/plugins/thirdparty/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,23 @@ module.exports = {
const cpuPerTool = {};
if (message.data.cpu && message.data.cpu.urls) {
for (let ent of message.data.cpu.urls) {
let entity = getEntity(ent.url);
// fallback to domain
if (!entity) {
const hostname = ent.url.startsWith('http')
? urlParser.parse(ent.url).hostname
: ent.url;
entity = {
name: hostname
};
}
if (cpuPerTool[entity.name]) {
cpuPerTool[entity.name] += ent.value;
} else {
cpuPerTool[entity.name] = ent.value;
// Seen errors like "Unable to find domain in "about:blank"
if (ent.url && ent.url.startsWith('http')) {
let entity = getEntity(ent.url);
// fallback to domain
if (!entity) {
const hostname = ent.url.startsWith('http')
? urlParser.parse(ent.url).hostname
: ent.url;
entity = {
name: hostname
};
}
if (cpuPerTool[entity.name]) {
cpuPerTool[entity.name] += ent.value;
} else {
cpuPerTool[entity.name] = ent.value;
}
}
}
}
Expand Down

0 comments on commit c6670af

Please sign in to comment.