# File lib/asciidoctor/path_resolver.rb, line 218
  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 (or file:///sample/path in browser environment)
        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 twice for a file:/// path and adjust root
    # NOTE technically file:/// paths work without this adjustment
    #elsif ::RUBY_ENGINE_OPAL && ::JAVASCRIPT_PLATFORM == 'browser' && root == 'file:/'
    #  root = 'file://'
    #  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