* The path.dirname() method returns the directory name of a path, * similar to the Unix dirname command. * Trailing directory separators are ignored. * @param {string} path * @returns {string}
(path)
| 7 | * @returns {string} |
| 8 | */ |
| 9 | dirname(path) { |
| 10 | if (path.endsWith("/")) path = path.slice(0, -1); |
| 11 | const parts = path.split("/").slice(0, -1); |
| 12 | if (!/^(\.|\.\.|)$/.test(parts[0])) parts.unshift("."); |
| 13 | const res = parts.join("/"); |
| 14 | |
| 15 | if (!res) return "/"; |
| 16 | else return res; |
| 17 | }, |
| 18 | |
| 19 | /** |
| 20 | * The path.basename() methods returns the last portion of a path, |
nothing calls this directly
no outgoing calls
no test coverage detected