Skip to content

Commit 2f2a21a

Browse files
XL-YiBaiysfscream
authored andcommitted
fix(desktop): fix the bug of topic filtering
1 parent d60d4b4 commit 2f2a21a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/database/services/MessageService.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default class MessageService {
88
constructor(
99
@InjectRepository(MessageEntity)
1010
private messageRepository: Repository<MessageEntity>,
11-
) {}
11+
) { }
1212

1313
public static modelToEntity(model: MessageModel, connectionId: string | undefined): MessageEntity {
1414
return {
@@ -64,7 +64,7 @@ export default class MessageService {
6464
if (topic.startsWith('$share/')) topic = topic.split('/').slice(2).join('/')
6565
if (topic.includes('#')) topic = topic.replace('/#', '%')
6666
if (topic.includes('+')) topic = topic.replace('+', '%')
67-
query.andWhere('msg.topic LIKE :topic', { topic })
67+
query.andWhere('msg.topic LIKE :topic ESCAPE "\\"', { topic })
6868
}
6969

7070
if (options.searchParams) {
@@ -121,7 +121,7 @@ export default class MessageService {
121121
if (topic.startsWith('$share/')) topic = topic.split('/').slice(2).join('/')
122122
if (topic.includes('#')) topic = topic.replace('/#', '%')
123123
if (topic.includes('+')) topic = topic.replace('+', '%')
124-
query.andWhere('msg.topic LIKE :topic', { topic })
124+
query.andWhere('msg.topic LIKE :topic ESCAPE "\\"', { topic })
125125
}
126126

127127
if (options.searchParams) {

0 commit comments

Comments
 (0)