Added slug as dependecy and created a slugified String
This commit is contained in:
parent
3d5e69b8a1
commit
c5fa1aecb9
|
@ -1,7 +1,14 @@
|
|||
import XRegExp from 'xregexp';
|
||||
import slug from 'slug';
|
||||
|
||||
// Matches letters from any alphabet and numbers
|
||||
const likeStringRegex = new XRegExp('[^\\p{L}\\p{Nd}]', 'g');
|
||||
export const sanitizeLikeString = str => str?.replace(likeStringRegex, '_');
|
||||
|
||||
export const slugifyLikeString = (str) => {
|
||||
str?.replace(likeStringRegex, '_');
|
||||
const slugified = slug(str);
|
||||
return slugified;
|
||||
};
|
||||
|
||||
export const sanitizer = r => r;
|
||||
|
|
|
@ -62,7 +62,7 @@ import { useSsl } from '../utils/url';
|
|||
import UserPreferences from './userPreferences';
|
||||
import { Encryption } from './encryption';
|
||||
import EventEmitter from '../utils/events';
|
||||
import { sanitizeLikeString } from './database/utils';
|
||||
import { sanitizeLikeString, slugifyLikeString } from './database/utils';
|
||||
import { updatePermission } from '../actions/permissions';
|
||||
import { TEAM_TYPE } from '../definition/ITeam';
|
||||
import { updateSettings } from '../actions/settings';
|
||||
|
@ -689,10 +689,12 @@ const RocketChat = {
|
|||
const searchText = text.trim();
|
||||
const db = database.active;
|
||||
const likeString = sanitizeLikeString(searchText);
|
||||
const slugifiedString = slugifyLikeString(searchText);
|
||||
let data = await db.get('subscriptions').query(
|
||||
Q.or(
|
||||
Q.where('name', Q.like(`%${ likeString }%`)),
|
||||
Q.where('fname', Q.like(`%${ likeString }%`))
|
||||
Q.where('fname', Q.like(`%${ likeString }%`)),
|
||||
Q.where('name', Q.like(`%${ slugifiedString }%`))
|
||||
),
|
||||
Q.experimentalSortBy('room_updated_at', Q.desc)
|
||||
).fetch();
|
||||
|
|
|
@ -119,6 +119,7 @@
|
|||
"rn-fetch-blob": "0.12.0",
|
||||
"rn-root-view": "1.0.3",
|
||||
"semver": "7.3.5",
|
||||
"slug": "^5.1.0",
|
||||
"ua-parser-js": "0.7.28",
|
||||
"url-parse": "1.5.1",
|
||||
"use-deep-compare-effect": "1.6.1",
|
||||
|
|
|
@ -15462,6 +15462,11 @@ slide@^1.1.5:
|
|||
resolved "https://registry.yarnpkg.com/slide/-/slide-1.1.6.tgz#56eb027d65b4d2dce6cb2e2d32c4d4afc9e1d707"
|
||||
integrity sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=
|
||||
|
||||
slug@^5.1.0:
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/slug/-/slug-5.1.0.tgz#8a7e30ca1c3a6dc40cf74e269750913a865edb0b"
|
||||
integrity sha512-IS39jKR6m+puU8zWgH6ruwx1sfzFNJ6Ai5PKIlUqd0X8C3ca7PB49Cvm0uayqgEt1jgaojO2wWEsQJngnh7fDA==
|
||||
|
||||
snapdragon-node@^2.0.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b"
|
||||
|
|
Loading…
Reference in New Issue