dirname(path) {
		if (path.endsWith("/")) path = path.slice(0, -1);
		const parts = path.split("/").slice(0, -1);
		if (!/^(\.|\.\.|)$/.test(parts[0])) parts.unshift(".");
		const res = parts.join("/");

		if (!res) return "/";
		else return res;
	}
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}