File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change 6
6
from data .connection import db_cursor
7
7
from data .users import User
8
8
9
+ import re
10
+
9
11
10
12
@dataclass
11
13
class Bloom :
@@ -16,7 +18,7 @@ class Bloom:
16
18
17
19
18
20
def add_bloom (* , sender : User , content : str ) -> Bloom :
19
- hashtags = [ word [ 1 :] for word in content . split ( " " ) if word . startswith ( "#" )]
21
+ hashtags = re . findall ( r"#(\w+)" , content )
20
22
21
23
now = datetime .datetime .now (tz = datetime .UTC )
22
24
bloom_id = int (now .timestamp () * 1000000 )
Original file line number Diff line number Diff line change @@ -37,8 +37,8 @@ const createBloom = (template, bloom) => {
37
37
function _formatHashtags ( text ) {
38
38
if ( ! text ) return text ;
39
39
return text . replace (
40
- / \B # [ ^ # ] + / g ,
41
- ( match ) => `<a href="/hashtag/${ match . slice ( 1 ) } ">${ match } </a>`
40
+ / # ( [ \p { L } 0 - 9 _ ] + ) / gu ,
41
+ ( _ , tag ) => `<a href="/hashtag/${ encodeURIComponent ( tag ) } "># ${ tag } </a>`
42
42
) ;
43
43
}
44
44
You can’t perform that action at this time.
0 commit comments