From c01a5ee85e2d6a7128cccafb143bfa694284ca87 Mon Sep 17 00:00:00 2001 From: kazu Date: Tue, 4 Dec 2018 08:22:10 +0000 Subject: Use delete_prefix instead of `sub(/\Afixed-pattern/, '')` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/cgi/core.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/cgi') diff --git a/lib/cgi/core.rb b/lib/cgi/core.rb index 3fb8dbab54..c45f9b3a9e 100644 --- a/lib/cgi/core.rb +++ b/lib/cgi/core.rb @@ -421,7 +421,7 @@ class CGI module QueryExtension %w[ CONTENT_LENGTH SERVER_PORT ].each do |env| - define_method(env.sub(/^HTTP_/, '').downcase) do + define_method(env.delete_prefix('HTTP_').downcase) do (val = env_table[env]) && Integer(val) end end @@ -434,7 +434,7 @@ class CGI HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_FROM HTTP_HOST HTTP_NEGOTIATE HTTP_PRAGMA HTTP_REFERER HTTP_USER_AGENT ].each do |env| - define_method(env.sub(/^HTTP_/, '').downcase) do + define_method(env.delete_prefix('HTTP_').downcase) do env_table[env] end end -- cgit v1.2.1