1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-13 13:50:07 +00:00

feat(tag): support search tags (#7450)

This commit is contained in:
Jerry Ren
2025-02-09 17:59:27 +08:00
committed by GitHub
parent 89382b4efb
commit 4c15cafb72
12 changed files with 530 additions and 34 deletions

View File

@@ -0,0 +1,22 @@
const escapeRegExp = (value) => {
if (typeof value !== 'string') return '';
return value.replace(/[.\\[\]{}()|^$?*+]/g, '\\$&');
};
export const getSearchRule = (value) => {
if (typeof value !== 'string') {
return false;
}
let searchRule = value;
searchRule = searchRule.trim();
if (searchRule.length === 0) {
return false;
}
// i: search value uppercase and lowercase are not sensitive
return new RegExp(escapeRegExp(searchRule), 'i');
};
export const checkHasSearchResult = (searchResult) => {
const { matchedCells } = searchResult || {};
return Array.isArray(matchedCells) ? matchedCells.length > 0 : false;
};