Unified · Split
| @@ -161,13 +161,13 @@ class App < Sinatra::Application · 160 unmodified lines | ||
| 161 | 161 | redirect 'http://www.reddit.com/submit?url=http%3A%2F%2Fdevdocs.io&title=All-in-one%2C%20quickly%20searchable%20API%20docs&resubmit=true' |
| 162 | 162 | end |
| 163 | 163 | |
| 164 | − get %r{\A/(\w+)(\-[\w\-]+)?(/)?(.+)?\z} do |doc, type, slash, rest| | |
| 164 | + get %r{\A/(\w+)(\-[\w\-]+)?(/.*)?\z} do |doc, type, rest| | |
| 165 | 165 | return 404 unless @doc = settings.docs[doc] |
| 166 | 166 | |
| 167 | − if !rest && !slash | |
| 167 | + if rest.nil? | |
| 168 | 168 | redirect "/#{doc}#{type}/" |
| 169 | − elsif rest && rest.end_with?('/') | |
| 170 | − redirect "#{doc}#{type}#{slash}#{rest[0...-1]}" | |
| 169 | + elsif rest.length > 1 && rest.end_with?('/') | |
| 170 | + redirect "/#{doc}#{type}#{rest[0...-1]}" | |
| 171 | 171 | else |
| 172 | 172 | erb :other |
| 173 | 173 | end |