diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 72bb44acfe..7f182e2907 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # external dependencies require 'rack' require 'tilt' @@ -268,7 +270,7 @@ def redirect(uri, *args) # Takes Rack routers and reverse proxies into account. def uri(addr = nil, absolute = true, add_script_name = true) return addr if addr =~ /\A[A-z][A-z0-9\+\.\-]*:/ - uri = [host = ""] + uri = [host = String.new] if absolute host << "http#{'s' if request.secure?}://" if request.forwarded? or request.port != (request.secure? ? 443 : 80) @@ -342,7 +344,7 @@ def content_type(type = nil, params = {}) # Set the Content-Disposition to "attachment" with the specified filename, # instructing the user agents to prompt to save. - def attachment(filename = nil, disposition = 'attachment') + def attachment(filename = nil, disposition = :attachment) response['Content-Disposition'] = disposition.to_s if filename params = '; filename="%s"' % File.basename(filename) @@ -360,8 +362,8 @@ def send_file(path, opts = {}) disposition = opts[:disposition] filename = opts[:filename] - disposition = 'attachment' if disposition.nil? and filename - filename = path if filename.nil? + disposition = :attachment if disposition.nil? and filename + filename = path if filename.nil? attachment(filename, disposition) if disposition last_modified opts[:last_modified] if opts[:last_modified] @@ -1299,7 +1301,7 @@ def inline_templates=(file = nil) data.each_line do |line| lines += 1 if line =~ /^@@\s*(.*\S)\s*$/ - template = force_encoding('', encoding) + template = force_encoding(String.new, encoding) templates[$1.to_sym] = [template, file, lines] elsif template template << line diff --git a/lib/sinatra/show_exceptions.rb b/lib/sinatra/show_exceptions.rb index 9aca060cf8..f17b90a6a5 100644 --- a/lib/sinatra/show_exceptions.rb +++ b/lib/sinatra/show_exceptions.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rack/show_exceptions' module Sinatra