lib/wicked_pdf/middleware.rb in wicked_pdf-0.11.0 vs lib/wicked_pdf/middleware.rb in wicked_pdf-1.0.0

- old
+ new

@@ -24,15 +24,15 @@ # Do not cache PDFs headers.delete('ETag') headers.delete('Cache-Control') - headers["Content-Length"] = (body.respond_to?(:bytesize) ? body.bytesize : body.size).to_s - headers["Content-Type"] = "application/pdf" + headers['Content-Length'] = (body.respond_to?(:bytesize) ? body.bytesize : body.size).to_s + headers['Content-Type'] = 'application/pdf' if @options.fetch(:disposition, '') == 'attachment' - headers["Content-Disposition"] = 'attachment' - headers["Content-Transfer-Encoding"] = 'binary' + headers['Content-Disposition'] = 'attachment' + headers['Content-Transfer-Encoding'] = 'binary' end end [status, headers, response] end @@ -79,13 +79,12 @@ end end def set_request_to_render_as_pdf(env) @render_pdf = true - path = @request.path.sub(%r{\.pdf$}, '') - %w[PATH_INFO REQUEST_URI].each { |e| env[e] = path } + %w(PATH_INFO REQUEST_URI).each { |e| env[e] = env[e].sub(%r{\.pdf\b}, '') } env['HTTP_ACCEPT'] = concat(env['HTTP_ACCEPT'], Rack::Mime.mime_type('.html')) - env["Rack-Middleware-WickedPdf"] = "true" + env['Rack-Middleware-WickedPdf'] = 'true' end def concat(accepts, type) (accepts || '').split(',').unshift(type).compact.join(',') end