Skip to content

Commit

Permalink
updating the search index
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulaBannerman committed Dec 12, 2024
1 parent 9c0d525 commit c0e593f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion search/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
fetch(searchEndpoint).then(function(res) {
return res.json()
}).then(function(posts) {
document.getElementById('search-params').innerHTML = urlParams.get('query');
document.getElementById('search-params').innerHTML = encodeHTML(urlParams.get('query'));
if (posts.web.results.length > 0) {
document.getElementById('search-results').classList.remove('display-none');
document.getElementById('no-results').classList.add('display-none');
Expand Down Expand Up @@ -48,6 +48,13 @@
document.getElementById('search-results').innerHTML = (append == true) ? previous + content : content;
}

function encodeHTML(str) {
return str.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
}
//]]>
</script>

Expand Down

0 comments on commit c0e593f

Please sign in to comment.