Fix to #114 - Accent insensitive search
This commit is contained in:
parent
82b2a0c95f
commit
699848283c
@ -482,7 +482,16 @@ angular.module('myApp.services', [])
|
||||
|
||||
.service('SearchIndexManager', function () {
|
||||
var badCharsRe = /[`~!@#$%^&*()\-_=+\[\]\\|{}'";:\/?.>,<\s]+/g,
|
||||
trimRe = /^\s+|\s$/g;
|
||||
trimRe = /^\s+|\s$/g,
|
||||
accentsReplace = {
|
||||
a: /[áâäà]/g,
|
||||
e: /[éêëè]/g,
|
||||
i: /[íîïì]/g,
|
||||
o: /[óôöò]/g,
|
||||
u: /[úûüù]/g,
|
||||
c: /ç/g,
|
||||
ss: /ß/g
|
||||
}
|
||||
|
||||
return {
|
||||
createIndex: createIndex,
|
||||
@ -504,6 +513,12 @@ angular.module('myApp.services', [])
|
||||
|
||||
searchText = searchText.replace(badCharsRe, ' ').replace(trimRe, '').toLowerCase();
|
||||
|
||||
for (var key in accentsReplace) {
|
||||
if (accentsReplace.hasOwnProperty(key)) {
|
||||
searchText = searchText.replace(accentsReplace[key], key);
|
||||
}
|
||||
}
|
||||
|
||||
if (!searchText.length) {
|
||||
return false;
|
||||
}
|
||||
@ -533,6 +548,12 @@ angular.module('myApp.services', [])
|
||||
|
||||
query = query.replace(badCharsRe, ' ').replace(trimRe, '').toLowerCase();
|
||||
|
||||
for (var key in accentsReplace) {
|
||||
if (accentsReplace.hasOwnProperty(key)) {
|
||||
query = query.replace(accentsReplace[key], key);
|
||||
}
|
||||
}
|
||||
|
||||
var queryWords = query.split(' '),
|
||||
foundObjs = false,
|
||||
newFoundObjs, i, j, searchText, found;
|
||||
|
Loading…
Reference in New Issue
Block a user