Sha256: c2847daacb5a46081558368fa236ea57e14c04c7968c718d7e0af0ac07da54c2

Contents?: true

Size: 849 Bytes

Versions: 10

Compression:

Stored size: 849 Bytes

Contents

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

10 entries across 10 versions & 1 rubygems

Version Path
roadie-3.5.1 lib/roadie/utils.rb
roadie-3.5.0 lib/roadie/utils.rb
roadie-3.4.0 lib/roadie/utils.rb
roadie-3.3.0 lib/roadie/utils.rb
roadie-3.2.2 lib/roadie/utils.rb
roadie-3.2.1 lib/roadie/utils.rb
roadie-3.2.0 lib/roadie/utils.rb
roadie-3.1.1 lib/roadie/utils.rb
roadie-3.1.0 lib/roadie/utils.rb
roadie-3.1.0.rc1 lib/roadie/utils.rb