Skip to content

Commit

Permalink
fix unicode search
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-roberts committed Nov 9, 2016
1 parent 374bfbb commit ad0d805
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion h/static/scripts/controllers/search-bar-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class SearchBarController extends Controller {
let inputFilter = stringUtil.fold(stringUtil.normalize(currentInput));

if(typeFilter === TAG_TYPE){
inputFilter = currentInput.substr(/*'tag:' len*/4);
inputFilter = inputFilter.substr(/*'tag:' len*/4);

// remove the initial quote for comparisons if it exists
if(inputFilter[0] === '\'' || inputFilter[0] === '"'){
Expand Down
13 changes: 13 additions & 0 deletions h/static/scripts/tests/controllers/search-bar-controller-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ describe('SearchBarController', function () {
tag: 'multi word',
count: 1,
},
{
tag: 'effort',
count: 1,
},
];

let tagsScript = document.createElement('script');
Expand Down Expand Up @@ -188,6 +192,15 @@ describe('SearchBarController', function () {
});
});

it('handles filtering matches with unicode', function(done){
syn
.click(input)
.type('tag:éf', () => {
assert.deepEqual(getItemTitles(), [ 'effort' ], 'matches éffort with unicode value');
done();
});
});

});
});

Expand Down
1 change: 1 addition & 0 deletions h/static/scripts/util/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function normalize(str){
// that is loaded globally on the running webpage
// not a require in the node context
try{
// polyfill String.prototype.normalize
require('unorm');
}catch(e){
console.error('unorm not available');
Expand Down

0 comments on commit ad0d805

Please sign in to comment.