def fast_relpath_optional(path, start):
  """A prefix-based relpath, with no normalization or support for returning `..`.

  Returns None if `start` is not a directory-aware prefix of `path`.
  """
  if len(start) == 0:
    # Empty prefix.
    return path

  # Determine where the matchable prefix ends.
  pref_end = len(start) - 1 if start[-1] == '/' else len(start)
  if pref_end > len(path):
    # The prefix is too long to match.
    return None
  elif path[:pref_end] == start[:pref_end] and (len(path) == pref_end or path[pref_end] == '/'):
    # The prefix matches, and the entries are either identical, or the suffix indicates that
    # the prefix is a directory.
    return path[pref_end+1:]
A prefix-based relpath, with no normalization or support for returning `..`.

  Returns None if `start` is not a directory-aware prefix of `path`.