@@ -748,10 +748,8 @@ impl Filter {
748
748
#[ inline]
749
749
fn search_match ( & self , event : & Event ) -> bool {
750
750
match & self . search {
751
- Some ( query) => event
752
- . content
753
- . split_whitespace ( )
754
- . any ( |word| word. eq_ignore_ascii_case ( query) ) ,
751
+ // TODO: best ways?
752
+ Some ( query) => event. content . to_lowercase ( ) . contains ( & query. to_lowercase ( ) ) ,
755
753
None => true ,
756
754
}
757
755
}
@@ -1124,6 +1122,34 @@ mod tests {
1124
1122
let filter: Filter = Filter :: new ( ) . search ( "test" ) . into ( ) ;
1125
1123
assert ! ( filter. match_event( & event) ) ;
1126
1124
}
1125
+
1126
+ #[ test]
1127
+ fn test_filter_search_match_event ( ) {
1128
+ let json: & str = r#"{
1129
+ "id": "3d1e30c357eba92568ba67138f9a508d29b306e5254952ee4d7c8039bd4a48fa",
1130
+ "pubkey": "68d81165918100b7da43fc28f7d1fc12554466e1115886b9e7bb326f65ec4272",
1131
+ "created_at": 1711027680,
1132
+ "kind": 0,
1133
+ "tags": [
1134
+ [
1135
+ "alt",
1136
+ "User profile for Yuki Kishimoto"
1137
+ ],
1138
+ [
1139
+ "i",
1140
+ "github:yukibtc",
1141
+ "69d9980b6e6b5d77a3e1e369ccaca9ba"
1142
+ ]
1143
+ ],
1144
+ "content": "{\"banner\":\"https://i.imgur.com/f1h1GgJ.jpg\",\"website\":\"https://yukikishimoto.com\",\"nip05\":\"[email protected] \",\"picture\":\"https://yukikishimoto.com/images/avatar.jpg\",\"lud16\":\"[email protected] \",\"display_name\":\"Yuki Kishimoto\",\"about\":\"GitHub: https://github.com/yukibtc\\nPGP: 86F3 105A DFA8 AB58 7268 DCD7 8D3D CD04 2496 19D1\",\"name\":\"Yuki Kishimoto\",\"displayName\":\"Yuki Kishimoto\"}",
1145
+ "sig": "27dddf90036cb7ea893eb13827342c49cbb72c442b3ac7b1f09081868b752d4c6e85882a881599e02a1374d4825e492e81703d44bce9728adccf66bb49f14220"
1146
+ }
1147
+ "# ;
1148
+ let event = Event :: from_json ( json) . unwrap ( ) ;
1149
+
1150
+ let filter = Filter :: new ( ) . search ( "Yuki kishi" ) ;
1151
+ assert ! ( filter. match_event( & event) ) ;
1152
+ }
1127
1153
}
1128
1154
1129
1155
#[ cfg( bench) ]
0 commit comments