Merge pull request #2127 from msafadieh/master

[fix] fix the browser autocomplete feature.
This commit is contained in:
Alexandre Flament 2020-08-09 19:21:09 +02:00 committed by GitHub
commit f3bfc19a55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -13,6 +13,6 @@
</Url>
{% endif %}
{% if autocomplete %}
<Url rel="suggestions" type="application/json" template="{{ host }}autocompleter"/>
<Url rel="suggestions" type="application/x-suggestions+json" template="{{ host }}autocompleter?q={searchTerms}"/>
{% endif %}
</OpenSearchDescription>

View File

@ -790,12 +790,12 @@ def autocompleter():
results.append(raw_text_query.getFullQuery())
# return autocompleter results
if request.form.get('format') == 'x-suggestions':
return Response(json.dumps([raw_text_query.query, results]),
if request.headers.get('X-Requested-With') == 'XMLHttpRequest':
return Response(json.dumps(results),
mimetype='application/json')
return Response(json.dumps(results),
mimetype='application/json')
return Response(json.dumps([raw_text_query.query, results]),
mimetype='application/x-suggestions+json')
@app.route('/preferences', methods=['GET', 'POST'])