浏览代码

fix: Allow CJK + Arabic chars in search queries

NGPixel 8 年之前
父节点
当前提交
8e6938483c
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      server/libs/search.js

+ 2 - 1
server/libs/search.js

@@ -7,6 +7,7 @@ const _ = require('lodash')
 const searchIndex = require('./search-index')
 const stopWord = require('stopword')
 const streamToPromise = require('stream-to-promise')
+const searchAllowedChars = new RegExp('[^a-z0-9' + appdata.regex.cjk + appdata.regex.arabic + ' ]', 'g')
 
 module.exports = {
 
@@ -160,7 +161,7 @@ module.exports = {
       .deburr()
       .toLower()
       .trim()
-      .replace(/[^a-z0-9 ]/g, ' ')
+      .replace(searchAllowedChars, ' ')
       .value()
     let arrTerms = _.chain(terms)
       .split(' ')