Sha256: 2ea94362a7f21117913b52a6670d86e32e86b8b492b5a165e0c7c09f6e1d762c

Contents?: true

Size: 820 Bytes

Versions: 3

Compression:

Stored size: 820 Bytes

Contents

# frozen_string_literal: true

module BreezyPDFLite::Intercept
  # :nodoc
  class Base
    attr_reader :app, :env

    def initialize(app, env)
      @app = app
      @env = env
    end

    private

    def rendered_url
      "#{base_url}#{path}#{query_string}"
    end

    def requested_url
      "#{env['rack.url_scheme']}://#{env['SERVER_NAME']}#{port}" \
      "#{env['PATH_INFO']}#{query_string}"
    end

    def base_url
      "#{env['rack.url_scheme']}://#{env['SERVER_NAME']}#{port}"
    end

    def port
      ":#{env['SERVER_PORT']}" unless [80, 443].include?(env["SERVER_PORT"].to_i)
    end

    def path
      env["PATH_INFO"].gsub(/\.pdf/, "")
    end

    def query_string
      return "" if env["QUERY_STRING"].nil?

      env["QUERY_STRING"] == "" ? "" : "?#{env['QUERY_STRING']}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
breezy_pdf_lite-0.0.7 lib/breezy_pdf_lite/intercept/base.rb
breezy_pdf_lite-0.0.6 lib/breezy_pdf_lite/intercept/base.rb
breezy_pdf_lite-0.0.4 lib/breezy_pdf_lite/intercept/base.rb