Sha256: 9a49602176f1bbf54ca30d9df6c398899d4d2facdf9cf909e510a007df01371b

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require 'addressable/uri'

require_relative 'absolutely/version'

require_relative 'absolutely/uri'

module Absolutely
  class Error < StandardError; end
  class ArgumentError < Error; end
  class InvalidURIError < Error; end

  # Convert a relative path to an absolute URI.
  #
  # @param base [String] an absolute URI used to resolve relative path
  # @param relative [String] a relative path
  # @return [String]
  #
  # @example
  #   Absolutely.to_abs(base: 'https://example.com', relative: '/foo')
  #   #=> "https://example.com/foo"
  def self.to_abs(base:, relative:)
    uri(base: base, relative: relative).to_abs
  end

  # Create an Absolutely::URI from a base URI and a relative path.
  #
  # @param base [String] an absolute URI used to resolve relative path
  # @param relative [String] a relative path
  # @return [Absolutely::URI]
  #
  # @example
  #   uri = Absolutely.uri(base: 'https://example.com', relative: '/foo')
  #   puts uri.to_abs
  #   #=> "https://example.com/foo"
  def self.uri(base:, relative:)
    URI.new(base: base, relative: relative)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
absolutely-6.0.0 lib/absolutely.rb