Fix and simplify doc route

pull/165/head
Thibaut 10 years ago
parent d0deb1b7d0
commit 9ec670c7d8

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

Loading…
Cancel
Save