Unified · Split
| @@ -287,7 +287,8 @@ class App < Sinatra::Application · 286 unmodified lines | ||
| 287 | 287 | 'angular~1.2' => 'angularjs~1.2' |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | − get %r{\A/([\w~\.]+)(\-[\w\-]+)?(/.*)?\z} do |doc, type, rest| | |
| 290 | + get %r{\A/([\w~\.%]+)(\-[\w\-]+)?(/.*)?\z} do |doc, type, rest| | |
| 291 | + doc.sub! '%7E', '~' | |
| 291 | 292 | return redirect "/#{DOC_REDIRECTS[doc]}#{type}#{rest}" if DOC_REDIRECTS.key?(doc) |
| 292 | 293 | return redirect "/angularjs/api#{rest}", 301 if doc == 'angular' && rest.start_with?('/ng') |
| 293 | 294 | return 404 unless @doc = find_doc(doc) |
| @@ -164,6 +164,14 @@ class AppTest < MiniTest::Spec · 163 unmodified lines | ||
| 164 | 164 | assert last_response.not_found? |
| 165 | 165 | end |
| 166 | 166 | |
| 167 | + it "decodes '~' properly" do | |
| 168 | + get '/html%7E5/' | |
| 169 | + assert last_response.ok? | |
| 170 | + | |
| 171 | + get '/html%7E42/' | |
| 172 | + assert last_response.not_found? | |
| 173 | + end | |
| 174 | + | |
| 167 | 175 | it "redirects with trailing slash" do |
| 168 | 176 | get '/html' |
| 169 | 177 | assert last_response.redirect? |