Skip to content

Commit 0b03256

Browse files
committed
Modify saniStrings(str) to rm empty spaces from beg, middle, end of search string
- Address user error: When user accidentally enters extra spaces - at start, middle, or end of search string entered in Search bar Signed-off-by: michael vincerra <michael.vincerra@intel.com>
1 parent bf89679 commit 0b03256

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/docs/_static/script.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ function attachSearch() {
163163
searchInput.addEventListener("input", e => {
164164
const value = e.target.value.replace(/\+/g, "\\+")
165165
const regex = new RegExp('.*' + saniStrings(value) + '.*', 'ig');
166+
// const cleaned = noExtraSpc(regex) /*rm extra empty spcs in search string*/
166167
search(regex);
167168
})
168169
};
@@ -177,10 +178,13 @@ function noResultsSwitch(data){
177178
}
178179

179180
function saniStrings(str) {
181+
/* remove reg/trademarks and all empty spaces */
180182
const reg_no_spcl = /[\u00ae\u2122\u2120\*]/g;
181-
return str.replace(reg_no_spcl, "");
183+
const result = str.replace(reg_no_spcl, "");
184+
return result.trim().replace(/\s+/g, " ");
182185
}
183186

187+
184188
function search(regex) {
185189
const data = state.data.filter(item => {
186190
const languages = item.languages.reduce((acc, value) => {

0 commit comments

Comments
 (0)