Address bar improvements

This commit is contained in:
Manoj Vivek 2020-07-22 09:31:49 +05:30
parent 84f900b923
commit e33b2f2f56
2 changed files with 16 additions and 2 deletions

View file

@ -60,6 +60,7 @@
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
cursor: default;
}
.searchBarSuggestionsListUl {
@ -70,8 +71,10 @@
.searchBarSuggestionsListItems:hover {
background: gray;
color: white;
}
.searchBarSuggestionsListItems.active {
background: gray;
color: white;
}

View file

@ -37,9 +37,17 @@ export const searchUrlUtils = url => {
return [];
};
const normalizeURL = url => {
if (url.indexOf('?') === -1 && !url.endsWith('/')) {
url = `${url}/`;
}
return url;
};
export const updateExistingUrl = url => {
url = normalizeURL(url);
if (previousSearchResults?.length) {
const updatedSearchResults = [...previousSearchResults];
let updatedSearchResults = [...previousSearchResults];
const index = updatedSearchResults.findIndex(
eachSearchResult => eachSearchResult.url === url
@ -49,7 +57,10 @@ export const updateExistingUrl = url => {
updatedSearchResults[index].visitedCount =
1 + updatedSearchResults[index].visitedCount;
} else {
updatedSearchResults.push({url, visitedCount: 1});
updatedSearchResults = [
{url, visitedCount: 1},
...updatedSearchResults,
].slice(0, 300);
}
addUrlToSearchResults(updatedSearchResults);