mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Decode "~" in url path
This commit is contained in:
parent
d5b372e254
commit
d0802988f1
2 changed files with 10 additions and 1 deletions
|
@ -287,7 +287,8 @@ class App < Sinatra::Application
|
|||
'angular~1.2' => 'angularjs~1.2'
|
||||
}
|
||||
|
||||
get %r{\A/([\w~\.]+)(\-[\w\-]+)?(/.*)?\z} do |doc, type, rest|
|
||||
get %r{\A/([\w~\.%]+)(\-[\w\-]+)?(/.*)?\z} do |doc, type, rest|
|
||||
doc.sub! '%7E', '~'
|
||||
return redirect "/#{DOC_REDIRECTS[doc]}#{type}#{rest}" if DOC_REDIRECTS.key?(doc)
|
||||
return redirect "/angularjs/api#{rest}", 301 if doc == 'angular' && rest.start_with?('/ng')
|
||||
return 404 unless @doc = find_doc(doc)
|
||||
|
|
|
@ -164,6 +164,14 @@ class AppTest < MiniTest::Spec
|
|||
assert last_response.not_found?
|
||||
end
|
||||
|
||||
it "decodes '~' properly" do
|
||||
get '/html%7E5/'
|
||||
assert last_response.ok?
|
||||
|
||||
get '/html%7E42/'
|
||||
assert last_response.not_found?
|
||||
end
|
||||
|
||||
it "redirects with trailing slash" do
|
||||
get '/html'
|
||||
assert last_response.redirect?
|
||||
|
|
Loading…
Reference in a new issue