-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
Milestone
Description
Pass in a file path with ASCII characters into the Uri
constructor and get the AbsoluteUri
:
> new Uri("/Users/tyleonha/Code/PowerShell/Misc/foo.ps1").AbsoluteUri
file:///Users/tyleonha/Code/PowerShell/Misc/foo.ps1
Everything looks great. Now pass in a path with non-ASCII characters:
> new Uri("/Users/tyleonha/Code/PowerShell/Misc/测试.ps1").AbsoluteUri
file:///Users/tyleonha/Code/PowerShell/Misc/%E6%B5%8B%E8%AF%95.ps1/Users/tyleonha/Code/PowerShell/Misc/%E6%B5%8B%E8%AF%95.ps1
The file is url encoded correctly but the file path is duplicated.
Same happens if I pass in the path a Uri string:
new Uri("file:///Users/tyleonha/Code/PowerShell/Misc/%E6%B5%8B%E8%AF%95.ps1").AbsoluteUri
file:///Users/tyleonha/Code/PowerShell/Misc/%E6%B5%8B%E8%AF%95.ps1/Users/tyleonha/Code/PowerShell/Misc/%E6%B5%8B%E8%AF%95.ps1
If I add a drive letter, this no longer repros:
> new Uri("C:/Users/tyleonha/Code/PowerShell/Misc/测试.ps1").AbsoluteUri
file:///C:/Users/tyleonha/Code/PowerShell/Misc/%E6%B5%8B%E8%AF%95.ps1
We know that the path passed in is absolute... so I'm a bit confused as to why this duplication is happening.
I'm running this on macOS Mojave with .NET Core 3.1 (via PowerShell).