class Asciidoctor::PathResolver

def partition_path path, web_path = false

QUESTION is it worth it to normalize slashes? it doubles the time elapsed
--
version of the path.
path root (e.g., '/', './', 'c:/') if the path is absolute and the posix
Returns a 3-item Array containing the Array of String path segments, the

as a web path (optional, default: false)
web_path - a Boolean indicating whether the path should be handled
path - the String path to partition

path before being partitioned.
or segments that are self references (.). The path is converted to a posix
Public: Partition the path into path segments and remove any empty segments
def partition_path path, web_path = false
  if (result = web_path ? @_partition_path_web[path] : @_partition_path_sys[path])
    return result
  end
  posix_path = posixfy path
  root = if web_path
    # ex. /sample/path
    if is_web_root? posix_path
      SLASH
    # ex. ./sample/path
    elsif posix_path.start_with? DOT_SLASH
      DOT_SLASH
    # ex. sample/path
    else
      nil
    end
  else
    if is_root? posix_path
      # ex. //sample/path
      if is_unc? posix_path
        DOUBLE_SLASH
      # ex. /sample/path
      elsif posix_path.start_with? SLASH
        SLASH
      # ex. c:/sample/path
      else
        posix_path[0..(posix_path.index SLASH)]
      end
    # ex. ./sample/path
    elsif posix_path.start_with? DOT_SLASH
      DOT_SLASH
    # ex. sample/path
    else
      nil
    end
  end
  path_segments = posix_path.split SLASH
  # shift twice for a UNC path
  if root == DOUBLE_SLASH
    path_segments = path_segments[2..-1]
  # shift once for any other root
  elsif root
    path_segments.shift
  end
  # strip out all dot entries
  path_segments.delete DOT
  # QUESTION should we chomp trailing /? (we pay a small fraction)
  #posix_path = posix_path.chomp '/'
  (web_path ? @_partition_path_web : @_partition_path_sys)[path] = [path_segments, root, posix_path]
end