Skip to content

Commit

Permalink
update const updateFromUrl with URLSearchParams (#2614)
Browse files Browse the repository at this point in the history
* update const updateFromUrl with URLSearchParams

* add fixes

* Apply suggestions from code review

remove semicolon

Co-authored-by: Mikhail Tokarev <[email protected]>

---------

Co-authored-by: Mikhail Tokarev <[email protected]>
  • Loading branch information
AstDaria and mikhail-tokarev authored Jun 26, 2024
1 parent 03dcfe0 commit 91308e3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions assets/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ const updateFromInput = (query) => {
}

const updateFromUrl = () => {
const query = decodeURIComponent((window.location.search || '').slice(3)) || null
if (window.location.search.indexOf('utm_') < 0) {
updateInput(query)
window.setTimeout(() => updateResults(query))
const params = window.location.search || ''
const searchParams = new URLSearchParams(params)
if (searchParams.has('q')) {
updateInput(searchParams.get('q'))
window.setTimeout(() => updateResults(searchParams.get('q')))
}
}

Expand Down

0 comments on commit 91308e3

Please sign in to comment.