Sha256: aca6c838cb69877c1d1559deaebb818dc025f264466bbb6f0fb46b30bb46e75c
Contents?: true
Size: 615 Bytes
Versions: 4
Compression:
Stored size: 615 Bytes
Contents
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/]) uri = find_uri_with_host url = "#{uri.scheme}://#{uri.hostname}" url << ":#{uri.port}" unless [80, 443].include?(uri.port) url << current_url url end def find_uri_with_host redirect_stack.reverse .map {|url| ::URI.parse(url) } .find {|uri| uri.scheme } end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
aitch-0.5.0 | lib/aitch/location.rb |
aitch-0.4.1 | lib/aitch/location.rb |
aitch-0.4.0 | lib/aitch/location.rb |
aitch-0.3.0 | lib/aitch/location.rb |