REFACTOR: isValidLink

- Reduced verbose comments
- Merged 2 `if` which had the same logic
This commit is contained in:
Régis Hanol 2020-01-08 18:14:24 +01:00 committed by GitHub
parent 6d6ffe5131
commit 92a9ae6ab0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,21 +8,13 @@ import ENV from "discourse-common/config/environment";
import User from "discourse/models/user";
export function isValidLink($link) {
// Do not track:
// - lightboxes
// - links with disabled tracking
// - category links
// - quote back button
// .hashtag == category/tag link
// .back == quote back ^ button
if ($link.is(".lightbox, .no-track-link, .hashtag, .back")) {
return false;
}
// Do not track links in quotes or in elided part
if ($link.parents("aside.quote, .elided").length !== 0) {
return false;
}
if ($link.parents(".expanded-embed").length !== 0) {
if ($link.parents("aside.quote, .elided, .expanded-embed").length !== 0) {
return false;
}