aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdijs <iamedijs@hotmail.com>2019-02-07 14:54:49 -0700
committerEdijs <iamedijs@hotmail.com>2019-02-07 14:54:49 -0700
commite44d8ad71eb1128ae53bfdd47ac81d3aa5d8ae07 (patch)
treebbe17705092ba67c630a59698e979496383e9a42 /src
parentc0b833cb85ccd10942accbefc3ba4d70cf3d745e (diff)
Extract tag name from href and open in same tab
Diffstat (limited to 'src')
-rw-r--r--src/components/status/status.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/components/status/status.js b/src/components/status/status.js
index 1ebb8a8d..a3b662b6 100644
--- a/src/components/status/status.js
+++ b/src/components/status/status.js
@@ -10,7 +10,7 @@ import LinkPreview from '../link-preview/link-preview.vue'
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
import fileType from 'src/services/file_type/file_type.service'
import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js'
-import { mentionMatchesUrl } from 'src/services/mention_matcher/mention_matcher.js'
+import { mentionMatchesUrl, extractTagFromUrl } from 'src/services/matcher/matcher.service.js'
import { filter, find } from 'lodash'
const Status = {
@@ -273,7 +273,7 @@ const Status = {
}
if (target.tagName === 'A') {
if (target.className.match(/mention/)) {
- const href = target.getAttribute('href')
+ const href = target.href
const attn = this.status.attentions.find(attn => mentionMatchesUrl(attn, href))
if (attn) {
event.stopPropagation()
@@ -282,8 +282,14 @@ const Status = {
this.$router.push(link)
return
}
- } else {
- this.$router.push(target.pathname)
+ }
+ if (target.className.match(/hashtag/)) {
+ // Extract tag name from link url
+ const tag = extractTagFromUrl(target.href)
+ if (tag) {
+ const link = this.generateTagLink(tag)
+ this.$router.push(link)
+ }
}
}
},
@@ -340,6 +346,9 @@ const Status = {
generateUserProfileLink (id, name) {
return generateProfileLink(id, name, this.$store.state.instance.restrictedNicknames)
},
+ generateTagLink (tag) {
+ return `/tag/${tag}`
+ },
setMedia () {
const attachments = this.attachmentSize === 'hide' ? this.status.attachments : this.galleryAttachments
return () => this.$store.dispatch('setMedia', attachments)