diff options
author | Go MAEDA <maeda@farend.jp> | 2019-03-27 02:15:24 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-03-27 02:15:24 +0000 |
commit | 72e1451159206af1c335b23e0c1e5bf9ed84bc85 (patch) | |
tree | 598902ed0066c4b292a6c1612aad4b203cbb81de /app/controllers/application_controller.rb | |
parent | f0d579adebfe3c5da93135fbaa3d9ec503d06855 (diff) | |
download | redmine-72e1451159206af1c335b23e0c1e5bf9ed84bc85.tar.gz redmine-72e1451159206af1c335b23e0c1e5bf9ed84bc85.zip |
Use Regexp#match? to reduce allocations of MatchData object (#28940).
Patch by Pavel Rosický.
git-svn-id: http://svn.redmine.org/redmine/trunk@18011 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 446cecc35..bf660c50b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -114,7 +114,7 @@ class ApplicationController < ActionController::Base if (key = api_key_from_request) # Use API key user = User.find_by_api_key(key) - elsif request.authorization.to_s =~ /\ABasic /i + elsif /\ABasic /i.match?(request.authorization.to_s) # HTTP Basic, either username/password or API key/random authenticate_with_http_basic do |username, password| user = User.try_to_login(username, password) || User.find_by_api_key(username) @@ -441,11 +441,11 @@ class ApplicationController < ActionController::Base path = uri.to_s # Ensure that the remaining URL starts with a slash, followed by a # non-slash character or the end - if path !~ %r{\A/([^/]|\z)} + if !%r{\A/([^/]|\z)}.match?(path) return false end - if path.match(%r{/(login|account/register|account/lost_password)}) + if %r{/(login|account/register|account/lost_password)}.match?(path) return false end @@ -626,7 +626,7 @@ class ApplicationController < ActionController::Base # Returns a string that can be used as filename value in Content-Disposition header def filename_for_content_disposition(name) - request.env['HTTP_USER_AGENT'] =~ %r{(MSIE|Trident|Edge)} ? ERB::Util.url_encode(name) : name + %r{(MSIE|Trident|Edge)}.match?(request.env['HTTP_USER_AGENT']) ? ERB::Util.url_encode(name) : name end def api_request? |