forked from Kieran/snort
This commit is contained in:
commit
fccb704f69
@ -131,7 +131,7 @@ export const TweetUrlRegex = /https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(?:
|
|||||||
* Hashtag regex
|
* Hashtag regex
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line no-useless-escape
|
// eslint-disable-next-line no-useless-escape
|
||||||
export const HashtagRegex = /(#[^\s!@#$%^&*()=+.\/,\[{\]};:'"?><]+)/;
|
export const HashtagRegex = /(#[^\s!@#$%^&*()=+.\/,\[{\]};:'"?><]+)/g;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tidal share link regex
|
* Tidal share link regex
|
||||||
|
@ -42,9 +42,14 @@ export class EventBuilder {
|
|||||||
*/
|
*/
|
||||||
processContent() {
|
processContent() {
|
||||||
if (this.#content) {
|
if (this.#content) {
|
||||||
this.#content = this.#content
|
this.#content = this.#content.replace(/@n(pub|profile|event|ote|addr|)1[acdefghjklmnpqrstuvwxyz023456789]+/g, m =>
|
||||||
.replace(/@n(pub|profile|event|ote|addr|)1[acdefghjklmnpqrstuvwxyz023456789]+/g, m => this.#replaceMention(m))
|
this.#replaceMention(m)
|
||||||
.replace(HashtagRegex, m => this.#replaceHashtag(m));
|
);
|
||||||
|
|
||||||
|
const hashTags = [...this.#content.matchAll(HashtagRegex)];
|
||||||
|
hashTags.map(hashTag => {
|
||||||
|
this.#addHashtag(hashTag[0]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -95,9 +100,8 @@ export class EventBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#replaceHashtag(match: string) {
|
#addHashtag(match: string) {
|
||||||
const tag = match.slice(1);
|
const tag = match.slice(1);
|
||||||
this.tag(["t", tag.toLowerCase()]);
|
this.tag(["t", tag.toLowerCase()]);
|
||||||
return match;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user