From ad0d8052cdeba348f822c3d41c3b74a540b4fa35 Mon Sep 17 00:00:00 2001 From: Sean Roberts Date: Wed, 9 Nov 2016 12:33:24 -0500 Subject: [PATCH] fix unicode search --- .../scripts/controllers/search-bar-controller.js | 2 +- .../tests/controllers/search-bar-controller-test.js | 13 +++++++++++++ h/static/scripts/util/string.js | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/h/static/scripts/controllers/search-bar-controller.js b/h/static/scripts/controllers/search-bar-controller.js index 784a631dd5c..0c0c9dea7b8 100644 --- a/h/static/scripts/controllers/search-bar-controller.js +++ b/h/static/scripts/controllers/search-bar-controller.js @@ -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] === '"'){ diff --git a/h/static/scripts/tests/controllers/search-bar-controller-test.js b/h/static/scripts/tests/controllers/search-bar-controller-test.js index c887d0ce653..0b70f6f06c5 100644 --- a/h/static/scripts/tests/controllers/search-bar-controller-test.js +++ b/h/static/scripts/tests/controllers/search-bar-controller-test.js @@ -81,6 +81,10 @@ describe('SearchBarController', function () { tag: 'multi word', count: 1, }, + { + tag: 'effort', + count: 1, + }, ]; let tagsScript = document.createElement('script'); @@ -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(); + }); + }); + }); }); diff --git a/h/static/scripts/util/string.js b/h/static/scripts/util/string.js index f20b420a595..cc4a09eefef 100644 --- a/h/static/scripts/util/string.js +++ b/h/static/scripts/util/string.js @@ -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');