You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
The text was updated successfully, but these errors were encountered:
Related possibly... the ToString() method shows similar (but worse) behavior:
> new Uri("/Users/tyleonha/Code/PowerShell/Misc/测试.ps1").ToString()
file:///Users/tyleonha/Code/PowerShell/Misc/%E6%B5%8B%E8%AF%95.ps1/Users/tyleonha/Code/PowerShell/Misc/测试.ps1
Some of the characters are decoded, some are left as is...
I went as deep as I could with the AbsoluteUri codepath but got to this method (ran with reflection) still gave me the same results... so it's deeper but what this is method is doing is over my head, I'm afraid.
Pass in a file path with ASCII characters into the
Uri
constructor and get theAbsoluteUri
:Everything looks great. Now pass in a path with non-ASCII characters:
The file is url encoded correctly but the file path is duplicated.
Same happens if I pass in the path a Uri string:
If I add a drive letter, this no longer repros:
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).
The text was updated successfully, but these errors were encountered: