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