Skip to content

Support current in URL #1417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ class ApplicationController < ActionController::Base
after_action :set_feature_headers

def set_ruby_version
if params[:version] == "current"
permitted_params = params.permit(:object, :engine, :q, :page, :theme)
redirect_to permitted_params.merge(version: RubyConfig.default_ruby_version.version)

Check warning

Code scanning / CodeQL

URL redirection from remote source

Untrusted URL redirection depends on a [user-provided value](1).
return
end

version = RubyConfig.version_for(params[:version]) || RubyConfig.default_ruby_version

Current.ruby_version = version
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

ruby_versions = RubyConfig.ruby_versions.collect { |v| Regexp.escape(v.version) }

scope "(:version)", constraints: { version: /#{ruby_versions.join("|")}/ } do
scope "(:version)", constraints: { version: /#{ruby_versions.join("|")}|current/ } do
root to: "home#index", as: :versioned_root
post '/set_theme', to: 'home#set_theme'
# We need the search path to be prefixed with `o/` so that the RDOc links will
Expand Down