Sha256: e08291869b973643e13d27d3fe43b515ba6c08ce6a36fd9d8eedb985efe65c3a

Contents?: true

Size: 885 Bytes

Versions: 5

Compression:

Stored size: 885 Bytes

Contents

# frozen_string_literal: true

module Roadie
  module Utils
    # @api private
    def path_is_absolute?(path)
      # Ruby's URI is pretty unforgiving, but roadie aims to be. Don't involve
      # URI for URLs that's easy to determine to be absolute.
      # URLs starting with a scheme (http:, data:) are absolute.
      #
      # URLs that start with double slashes (//css/app.css) are also absolute
      # in modern browsers, but most email clients do not understand them.
      return true if %r{^(\w+:|//)}.match?(path)

      begin
        !URI.parse(path).relative?
      rescue URI::InvalidURIError => error
        raise InvalidUrlPath.new(path, error)
      end
    end
    # @api private
    module_function :path_is_absolute?

    # @api private
    def warn(message)
      Kernel.warn("Roadie: #{message}")
    end
    # @api private
    module_function :warn
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
roadie-5.2.1 lib/roadie/utils.rb
roadie-5.2.0 lib/roadie/utils.rb
roadie-5.1.0 lib/roadie/utils.rb
roadie-5.0.1 lib/roadie/utils.rb
roadie-5.0.0 lib/roadie/utils.rb