BigW Consortium Gitlab

Commit 7b02d450 by Filipa Lacerda Committed by James Lopez

Merge branch 'fix-filtering-username-with-multiple-words' into 'master'

Fix filtering usernames with multiple words Closes #27404 See merge request !8851
parent c759724f
...@@ -39,8 +39,15 @@ ...@@ -39,8 +39,15 @@
getSearchInput() { getSearchInput() {
const query = gl.DropdownUtils.getSearchInput(this.input); const query = gl.DropdownUtils.getSearchInput(this.input);
const { lastToken } = gl.FilteredSearchTokenizer.processTokens(query); const { lastToken } = gl.FilteredSearchTokenizer.processTokens(query);
let value = lastToken.value || '';
return lastToken.value || ''; // Removes the first character if it is a quotation so that we can search
// with multiple words
if (value[0] === '"' || value[0] === '\'') {
value = value.slice(1);
}
return value;
} }
init() { init() {
......
---
title: Fix filtering usernames with multiple words
merge_request: 8851
author:
//= require filtered_search/dropdown_utils
//= require filtered_search/filtered_search_tokenizer
//= require filtered_search/filtered_search_dropdown
//= require filtered_search/dropdown_user
(() => {
describe('Dropdown User', () => {
describe('getSearchInput', () => {
let dropdownUser;
beforeEach(() => {
spyOn(gl.FilteredSearchDropdown.prototype, 'constructor').and.callFake(() => {});
spyOn(gl.DropdownUser.prototype, 'getProjectId').and.callFake(() => {});
spyOn(gl.DropdownUtils, 'getSearchInput').and.callFake(() => {});
dropdownUser = new gl.DropdownUser();
});
it('should not return the double quote found in value', () => {
spyOn(gl.FilteredSearchTokenizer, 'processTokens').and.returnValue({
lastToken: {
value: '"johnny appleseed',
},
});
expect(dropdownUser.getSearchInput()).toBe('johnny appleseed');
});
it('should not return the single quote found in value', () => {
spyOn(gl.FilteredSearchTokenizer, 'processTokens').and.returnValue({
lastToken: {
value: '\'larry boy',
},
});
expect(dropdownUser.getSearchInput()).toBe('larry boy');
});
});
});
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment