Skip to content

Commit

Permalink
fix domain extraction in undertone adapter (#2921)
Browse files Browse the repository at this point in the history
* fix domain extraction in undertone adapter

There was a bug when trying to extract domain from hostnames with two letter suffixes such as .co / .io / etc
This fix solves this issue

* fix lint issues
  • Loading branch information
omerko authored and mike-chowla committed Aug 3, 2018
1 parent 198013e commit aca5fb7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions modules/undertoneBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ export const spec = {
'x-ut-hb-params': []
};
const location = utils.getTopWindowLocation();
let domain = /[-\w]+\.(?:[-\w]+\.xn--[-\w]+|[-\w]{3,}|[-\w]+\.[-\w]{2})$/i.exec(location.host);
if (domain == null || domain.length == 0) {
domain = null;
} else {
domain = domain[0];
let domains = /[-\w]+\.([-\w]+|[-\w]{3,}|[-\w]{1,3}\.[-\w]{2})$/i.exec(location.host);
let domain = null;
if (domains != null && domains.length > 0) {
domain = domains[0];
for (let i = 1; i < domains.length; i++) {
if (domains[i].length > domain.length) {
domain = domains[i];
}
}
}

const pubid = validBidRequests[0].params.publisherId;
Expand Down

0 comments on commit aca5fb7

Please sign in to comment.