Unified · Split
| @@ -105,6 +105,10 @@ class App < Sinatra::Application · 104 unmodified lines | |||
| 105 | def doc_index_page? | 105 | def doc_index_page? |
| 106 | @doc && request.path == "/#{@doc['slug']}/" | 106 | @doc && request.path == "/#{@doc['slug']}/" |
| 107 | end | 107 | end |
| 108 | |||
| 109 | def query_string_for_redirection | ||
| 110 | request.query_string.empty? ? nil : "?#{request.query_string}" | ||
| 111 | end | ||
| 108 | end | 112 | end |
| 109 | 113 | ||
| 110 | before do | 114 | before do |
| @@ -165,9 +169,9 @@ class App < Sinatra::Application · 54 unmodified lines | |||
| 165 | return 404 unless @doc = settings.docs[doc] | 169 | return 404 unless @doc = settings.docs[doc] |
| 166 | 170 | ||
| 167 | if rest.nil? | 171 | if rest.nil? |
| 168 | redirect "/#{doc}#{type}/" | 172 | redirect "/#{doc}#{type}/#{query_string_for_redirection}" |
| 169 | elsif rest.length > 1 && rest.end_with?('/') | 173 | elsif rest.length > 1 && rest.end_with?('/') |
| 170 | redirect "/#{doc}#{type}#{rest[0...-1]}" | 174 | redirect "/#{doc}#{type}#{rest[0...-1]}#{query_string_for_redirection}" |
| 171 | else | 175 | else |
| 172 | erb :other | 176 | erb :other |
| 173 | end | 177 | end |