mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Fix keyword search in Firefox and URL search via query param
Fixes #577.
This commit is contained in:
parent
476c69e419
commit
ad044f85d3
3 changed files with 8 additions and 1 deletions
|
@ -229,6 +229,7 @@ class App < Sinatra::Application
|
|||
end
|
||||
|
||||
get '/' do
|
||||
return redirect "/#q=#{params[:q]}" if params[:q]
|
||||
return redirect '/' unless request.query_string.empty? # courtesy of HTML5 App Cache
|
||||
response.headers['Content-Security-Policy'] = settings.csp if settings.csp
|
||||
erb :index
|
||||
|
|
|
@ -17,6 +17,12 @@ class AppTest < MiniTest::Spec
|
|||
assert last_response.ok?
|
||||
end
|
||||
|
||||
it "redirects to /#q= when there is a 'q' query param" do
|
||||
get '/search', q: 'foo'
|
||||
assert last_response.redirect?
|
||||
assert_equal 'http://example.org/#q=foo', last_response['Location']
|
||||
end
|
||||
|
||||
it "redirects without the query string" do
|
||||
get '/', foo: 'bar'
|
||||
assert last_response.redirect?
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<button type="button" class="_mobile-btn _menu-btn">Menu</button>
|
||||
<button type="button" class="_mobile-btn _home-btn">Home</button>
|
||||
<form class="_search" role="search">
|
||||
<input type="search" class="_search-input" placeholder="Search…" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" maxlength="30" aria-label="Search">
|
||||
<input type="search" name="q" class="_search-input" placeholder="Search…" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" maxlength="30" aria-label="Search">
|
||||
<button type="reset" class="_search-clear" title="Clear search">Clear search</button>
|
||||
<div class="_search-tag"></div>
|
||||
</form>
|
||||
|
|
Loading…
Reference in a new issue