Skip to content

Commit

Permalink
Redirect to /query URL in shortcut case.
Browse files Browse the repository at this point in the history
This works around the problem with the solution for #583 that we cannot
access the URL fragment returned by the redirect using JS API.

It can be replaced by a call to the shortcut API outlined in
faustedition/faust-gen-html#654 once that is
in place.
  • Loading branch information
thvitt committed May 13, 2021
1 parent 23a3d92 commit 576249a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions search.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,12 @@ function performSearches() {
ev.preventDefault();
let data = new FormData(ev.target);
state.current.q = data.get('q');
fetch('/query?' + new URLSearchParams(data).toString())
const queryUrl = '/query?' + new URLSearchParams(data).toString()
fetch(queryUrl)
.then(function (response) {
let url = new URL(response.url);
if (!url.pathname.startsWith('/search')) {
window.location = url; // redirect
window.location = queryUrl; // redirect
} else {
state.toLocation();
state.toForm();
Expand Down

0 comments on commit 576249a

Please sign in to comment.