Sha256: 92a2cb26c3b4f6848ae1fe109990644b3beb72fe4fb3fc6357269902fa201e63
Contents?: true
Size: 708 Bytes
Versions: 2
Compression:
Stored size: 708 Bytes
Contents
# frozen_string_literal: true module Aitch class Location attr_reader :redirect_stack, :current_url def initialize(redirect_stack, current_url) @redirect_stack = redirect_stack @current_url = current_url end def location return current_url unless current_url.match?(%r{\A/}) # rubocop:disable Performance/StartWith uri = find_uri_with_host url = ["#{uri.scheme}://#{uri.hostname}"] url << ":#{uri.port}" unless [80, 443].include?(uri.port) url << current_url url.join end def find_uri_with_host redirect_stack.reverse .map {|url| ::URI.parse(url) } .find(&:scheme) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aitch-1.2.1 | lib/aitch/location.rb |
aitch-1.2.0 | lib/aitch/location.rb |