FIX: Skip attachments in click track.
This commit is contained in:
parent
f530048973
commit
861023f0d6
|
@ -52,6 +52,11 @@ export default {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let href = ($link.attr("href") || $link.data("href") || "").trim();
|
||||||
|
if (!href || href.indexOf("mailto:") === 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if ($link.hasClass("attachment")) {
|
if ($link.hasClass("attachment")) {
|
||||||
// Warn the user if they cannot download the file.
|
// Warn the user if they cannot download the file.
|
||||||
if (
|
if (
|
||||||
|
@ -59,15 +64,14 @@ export default {
|
||||||
!Discourse.User.current()
|
!Discourse.User.current()
|
||||||
) {
|
) {
|
||||||
bootbox.alert(I18n.t("post.errors.attachment_download_requires_login"));
|
bootbox.alert(I18n.t("post.errors.attachment_download_requires_login"));
|
||||||
return false;
|
} 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(
|
const $article = $link.closest(
|
||||||
|
|
|
@ -70,13 +70,13 @@ QUnit.test("does not track elements with no href", async assert => {
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("does not track attachments", async assert => {
|
QUnit.test("does not track attachments", async assert => {
|
||||||
assert.expect(1);
|
|
||||||
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
|
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
|
||||||
|
|
||||||
/* global server */
|
/* global server */
|
||||||
server.post("/clicks/track", () => assert.ok(false));
|
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 => {
|
QUnit.test("tracks external URLs", async assert => {
|
||||||
|
|
Loading…
Reference in New Issue