FIX: Skip attachments in click track.
This commit is contained in:
parent
f530048973
commit
861023f0d6
|
@ -52,6 +52,11 @@ export default {
|
|||
return true;
|
||||
}
|
||||
|
||||
let href = ($link.attr("href") || $link.data("href") || "").trim();
|
||||
if (!href || href.indexOf("mailto:") === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($link.hasClass("attachment")) {
|
||||
// Warn the user if they cannot download the file.
|
||||
if (
|
||||
|
@ -59,17 +64,16 @@ export default {
|
|||
!Discourse.User.current()
|
||||
) {
|
||||
bootbox.alert(I18n.t("post.errors.attachment_download_requires_login"));
|
||||
} else if (wantsNewWindow(e)) {
|
||||
const newWindow = window.open(href, "_blank");
|
||||
newWindow.opener = null;
|
||||
newWindow.focus();
|
||||
} else {
|
||||
DiscourseURL.redirectTo(href);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
let href = ($link.attr("href") || $link.data("href") || "").trim();
|
||||
if (!href || href.indexOf("mailto:") === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const $article = $link.closest(
|
||||
"article:not(.onebox-body), .excerpt, #revisions"
|
||||
);
|
||||
|
|
|
@ -70,13 +70,13 @@ QUnit.test("does not track elements with no href", async assert => {
|
|||
});
|
||||
|
||||
QUnit.test("does not track attachments", async assert => {
|
||||
assert.expect(1);
|
||||
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
|
||||
|
||||
/* global server */
|
||||
server.post("/clicks/track", () => assert.ok(false));
|
||||
|
||||
assert.ok(track(generateClickEventOn(".attachment")));
|
||||
assert.notOk(track(generateClickEventOn(".attachment")));
|
||||
assert.ok(DiscourseURL.redirectTo.calledWith("http://discuss.domain.com/uploads/default/1234/1532357280.txt"));
|
||||
});
|
||||
|
||||
QUnit.test("tracks external URLs", async assert => {
|
||||
|
|
Loading…
Reference in New Issue