function dirname(p) {
    // Normalize slashes and trim unnecessary trailing slash
    p = safeTrimTrailingSeparator(p);
    // Windows UNC root, e.g. \\hello or \\hello\world
    if (IS_WINDOWS && /^\\\\[^\\]+(\\[^\\]+)?$/.test(p)) {
        return p;
    }
    // Get dirname
    let result = path.dirname(p);
    // Trim trailing slash for Windows UNC root, e.g. \\hello\world\
    if (IS_WINDOWS && /^\\\\[^\\]+\\[^\\]+\\$/.test(result)) {
        result = safeTrimTrailingSeparator(result);
    }
    return result;
}
Similar to path.dirname except normalizes the path separators and slightly better handling for Windows UNC paths.

For example, on Linux/macOS:
- `/               => /`
- `/hello          => /`

For example, on Windows:
- `C:\             => C:\`
- `C:\hello        => C:\`
- `C:              => C:`
- `C:hello         => C:`
- `\               => \`
- `\hello          => \`
- `\\hello         => \\hello`
- `\\hello\world   => \\hello\world`