Sha256: c41d0cf1286c10930bc161cbd82a89ea3537ced4f946f4b4a65cc03443e6bed5

Contents?: true

Size: 880 Bytes

Versions: 1

Compression:

Stored size: 880 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 path =~ %r{^(\w+:|//)}

      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

1 entries across 1 versions & 1 rubygems

Version Path
roadie-4.0.0 lib/roadie/utils.rb