Sha256: df58a255f578dfa9affe074c29814fc068b029cc8c7bda16a117e66bc55687cf
Contents?: true
Size: 683 Bytes
Versions: 1
Compression:
Stored size: 683 Bytes
Contents
module Microformats class AbsoluteUri attr_accessor :base, :relative def initialize(relative, base: nil) @base = base @relative = relative @base.strip! unless @base.nil? @relative.strip! unless @relative.nil? end def absolutize #TODO: i'm sure this could be improved a bit return nil if relative.nil? or relative == "" return relative if relative =~ /^https?:\/\// uri = URI.parse(relative) if base && !uri.absolute? uri = URI.join(base.to_s, relative.to_s) end uri.normalize! uri.to_s rescue URI::BadURIError, URI::InvalidURIError => e relative.to_s end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
microformats-4.0.0 | lib/microformats/absolute_uri.rb |