lib/pdfkit/middleware.rb in pdfkit-0.7.0 vs lib/pdfkit/middleware.rb in pdfkit-0.8.0

- old
+ new

@@ -3,16 +3,16 @@ def initialize(app, options = {}, conditions = {}) @app = app @options = options @conditions = conditions @render_pdf = false + @caching = @conditions.delete(:caching) { false } end def call(env) @request = Rack::Request.new(env) @render_pdf = false - @caching = @conditions.delete(:caching) { false } set_request_to_render_as_pdf(env) if render_as_pdf? status, headers, response = @app.call(env) if rendering_pdf? && headers['Content-Type'] =~ /text\/html|application\/xhtml\+xml/ @@ -47,11 +47,11 @@ translate_relative_protocols(body, env) end def translate_relative_paths(body, env) root = PDFKit.configuration.root_url || "#{env['rack.url_scheme']}://#{env['HTTP_HOST']}/" - # Try out this regexp using rubular http://rubular.com/r/vmuGSkheuu - body.gsub(/(href|src)=(['"])\/([^\/]([^\"']*|[^"']*))['"]/, "\\1=\\2#{root}\\3\\2") + # Try out this regexp using rubular http://rubular.com/r/hiAxBNX7KE + body.gsub(/(href|src)=(['"])\/([^\/"']([^\"']*|[^"']*))?['"]/, "\\1=\\2#{root}\\3\\2") end def translate_relative_protocols(body, env) protocol = "#{env['rack.url_scheme']}://" # Try out this regexp using rubular http://rubular.com/r/0Ohk0wFYxV