sforkowany z mirror/social
Better regular expression to identify hashtags in Composer
Signed-off-by: Cyrille Bollu <cyrpub@bollu.be>feature/noid/sql-rewrite-0929
rodzic
b5b929472d
commit
9f19f71aa4
|
@ -584,29 +584,29 @@ export default {
|
|||
var em = document.createTextNode(emoji.getAttribute('alt'))
|
||||
emoji.replaceWith(em)
|
||||
})
|
||||
let content = element.innerText.trim()
|
||||
let contentHtml = element.innerHTML
|
||||
let to = []
|
||||
let hashtags = []
|
||||
const mentionRegex = /@(([\w-_.]+)(@[\w-.]+)?)/g
|
||||
let match = null
|
||||
do {
|
||||
match = mentionRegex.exec(content)
|
||||
match = mentionRegex.exec(contentHtml)
|
||||
if (match) {
|
||||
to.push(match[1])
|
||||
}
|
||||
} while (match)
|
||||
|
||||
const hashtagRegex = /#([\w-_.]+)/g
|
||||
const hashtagRegex = />#([^<]+)</g
|
||||
match = null
|
||||
do {
|
||||
match = hashtagRegex.exec(content)
|
||||
match = hashtagRegex.exec(contentHtml)
|
||||
if (match) {
|
||||
hashtags.push(match[1])
|
||||
}
|
||||
} while (match)
|
||||
|
||||
let data = {
|
||||
content: content,
|
||||
content: element.innerText.trim(),
|
||||
to: to,
|
||||
hashtags: hashtags,
|
||||
type: this.type
|
||||
|
|
Ładowanie…
Reference in New Issue