Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3339,8 +3339,11 @@ internal static string GetDriveQualifiedPath(string path, PSDriveInfo drive)
}
else
{
if (path.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal) ||
path.StartsWith(StringLiterals.AlternatePathSeparatorString, StringComparison.Ordinal))
// Check if the path begins with "\" or "/" (UNC Path or Path in Unix).
// Ignore if the path resolves to a drive path, this will happen when path is equal to "\" or "/".
// Drive path still need formatting, so treat them as relative.
if (path.Length > 1 && (path.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal) ||
path.StartsWith(StringLiterals.AlternatePathSeparatorString, StringComparison.Ordinal)))
{
treatAsRelative = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ Describe "Resolve-Path returns proper path" -Tag "CI" {
$_.fullyqualifiederrorid | should be "PathNotFound,Microsoft.PowerShell.Commands.ResolvePathCommand"
}
}
It "Resolve-Path -Path should return correct drive path" {
$result = Resolve-Path -Path "TestDrive:\\\\\"
($result.Path.TrimEnd('/\')) | Should Be "TestDrive:"
}
It "Resolve-Path -LiteralPath should return correct drive path" {
$result = Resolve-Path -LiteralPath "TestDrive:\\\\\"
($result.Path.TrimEnd('/\')) | Should Be "TestDrive:"
}
}