Merge pull request #21823 from shuuji3/fix-no-search-result-with-keywords-with-spaces

Fix the no search result error when the keyword includes spaces.
pull/22000/head
Kubernetes Prow Robot 2020-06-22 14:09:43 -07:00 committed by GitHub
commit 91e35967ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -11,7 +11,7 @@
}
window.getPaginationAnchors = (pages) => {
var pageAnchors = '', searchTerm = window.location.search.split("=")[1].split("&")[0];
var pageAnchors = '', searchTerm = window.location.search.split("=")[1].split("&")[0].replace(/%20/g, ' ');
var currentPage = window.location.search.split("=")[2];
currentPage = (!currentPage) ? 1 : currentPage.split("&")[0];
@ -33,7 +33,7 @@
}
window.renderBingSearchResults = () => {
var searchTerm = window.location.search.split("=")[1].split("&")[0],
var searchTerm = window.location.search.split("=")[1].split("&")[0].replace(/%20/g,' '),
page = window.location.search.split("=")[2],
q = "site:kubernetes.io " + searchTerm;
@ -47,6 +47,7 @@
ajaxConf.beforeSend = function(xhr){ xhr.setRequestHeader('Ocp-Apim-Subscription-Key', '51efd23677624e04b4abe921225ea7ec'); };
$.ajax(ajaxConf).done(function(res) {
if (res.webPages == null) return; // If no result, 'webPages' is 'undefined'
var paginationAnchors = window.getPaginationAnchors(Math.ceil(res.webPages.totalEstimatedMatches / 10));
res.webPages.value.map(ob => { results += window.getResultMarkupString(ob); })