mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
feat(full-text-search): enable forward for ascii text
This commit is contained in:
@@ -206,5 +206,19 @@ export const win32 = path => {
|
||||
};
|
||||
|
||||
export const searchTokenize = str => {
|
||||
return str.split(/\W+/).concat(str.replace(/[\x00-\x7F]/g, '').split('')).filter(e => !!e);
|
||||
let ascii_words = str.split(/\W+/);
|
||||
let non_ascii_str = str.replace(/[\x00-\x7F]/g, '');
|
||||
if (non_ascii_str == '') {
|
||||
// forward
|
||||
const length = str.length;
|
||||
let token = '';
|
||||
let tokens = [];
|
||||
for(let a = 0; a < length; a++){
|
||||
token += str[a];
|
||||
tokens.push(token);
|
||||
};
|
||||
return tokens;
|
||||
} else {
|
||||
return ascii_words.concat(non_ascii_str.split('')).filter(e => !!e);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user