class Asciidoctor::PathResolver
def web_path target, start = nil
start path with any parent references resolved and self
returns a String path that joins the target path with the
start - the String start (i.e., parent) path
target - the String target path
That check should happen before this method is invoked.
The target is assumed to be a path, not a qualified URI.
references and remove any self references.
The main function of this operation is to resolve any parent
Public: Resolve a web path from the target and start paths.
def web_path target, start = nil target = posixfy target start = posixfy start uri_prefix = nil unless start.nil_or_empty? || (is_web_root? target) target = %(#{start}#{SLASH}#{target}) if (target.include? ':') && UriSniffRx =~ target uri_prefix = $~[0] target = target[uri_prefix.length..-1] end end # use this logic instead if we want to normalize target if it contains a URI #unless is_web_root? target # if preserve_uri_target && (target.include? ':') && UriSniffRx =~ target # uri_prefix = $~[0] # target = target[uri_prefix.length..-1] # elsif !start.nil_or_empty? # target = %(#{start}#{SLASH}#{target}) # if (target.include? ':') && UriSniffRx =~ target # uri_prefix = $~[0] # target = target[uri_prefix.length..-1] # end # end #end target_segments, target_root, _ = partition_path target, true resolved_segments = [] target_segments.each do |segment| if segment == DOT_DOT if resolved_segments.empty? resolved_segments << segment unless target_root && target_root != DOT_SLASH elsif resolved_segments[-1] == DOT_DOT resolved_segments << segment else resolved_segments.pop end else resolved_segments << segment end end if uri_prefix %(#{uri_prefix}#{join_path resolved_segments, target_root}) else join_path resolved_segments, target_root end end