(path)
| 13801 | // "/foo/bar" ⇥ "/foo", "/foo" ⇥ "/", "/" ↦ "". (The root is special-cased |
| 13802 | // because the id of the root must be a truthy value.) |
| 13803 | function parentof(path) { |
| 13804 | let i = path.length; |
| 13805 | if (i < 2) return ""; |
| 13806 | while (--i > 1) if (slash(path, i)) break; |
| 13807 | return path.slice(0, i); |
| 13808 | } |
| 13809 | |
| 13810 | // Slashes can be escaped; to determine whether a slash is a path delimiter, we |
| 13811 | // count the number of preceding backslashes escaping the forward slash: an odd |