Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Commit

Permalink
fix(topstories): Closes #3029 Add ETLDs for top stories
Browse files Browse the repository at this point in the history
  • Loading branch information
sarracini committed Jul 31, 2017
1 parent fdab110 commit 96d1f42
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
11 changes: 10 additions & 1 deletion system-addon/lib/TopStoriesFeed.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ this.TopStoriesFeed = class TopStoriesFeed {
"description": s.excerpt,
"image": this._normalizeUrl(s.image_src),
"referrer": this.stories_referrer,
"url": s.dedupe_url
"url": s.dedupe_url,
"eTLD": this._addETLD(s.dedupe_url)
}));
return items;
})
Expand Down Expand Up @@ -162,6 +163,14 @@ this.TopStoriesFeed = class TopStoriesFeed {
return url;
}

_addETLD(url) {
try {
return Services.eTLD.getPublicSuffix(Services.io.newURI(url));
} catch (err) {
return "";
}
}

onAction(action) {
switch (action.type) {
case at.INIT:
Expand Down
3 changes: 2 additions & 1 deletion system-addon/test/unit/lib/TopStoriesFeed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ describe("Top Stories Feed", () => {
"description": "description",
"image": "image-url",
"referrer": "referrer",
"url": "rec-url"
"url": "rec-url",
"eTLD": ""
}];

instance.stories_endpoint = "stories-endpoint";
Expand Down
4 changes: 3 additions & 1 deletion system-addon/test/unit/unit-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ overrider.set({
};
}
},
tm: {dispatchToMainThread: cb => cb()}
tm: {dispatchToMainThread: cb => cb()},
eTLD: {getPublicSuffix() {}},
io: {NewURI() {}}
},
XPCOMUtils: {
defineLazyModuleGetter() {},
Expand Down

0 comments on commit 96d1f42

Please sign in to comment.