Skip to content

Don't rely on Uri.ToString() in Serializer #195

@TylerLeonhardt

Description

@TylerLeonhardt

In the AbsoluteUriConverter class, we use Uri.ToString().

Unfortunately, the Uri.ToString() has bizarre behavior with Uris with escaped non-ASCII characters.

> 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

Notice the path is written twice?

This only seems to happen on non-Windows as adding a drive letter fixes it... but then it url decodes the characters:

> new Uri("file:///C:/Users/tyleonha/Code/PowerShell/Misc/%E6%B5%8B%E8%AF%95.ps1").ToString()
file:///C:/Users/tyleonha/Code/PowerShell/Misc/测试.ps1

But then again... since VS Code expects the colon to be escaped in the drive letter... we're still left in a bad state:

new Uri("file:///C%3A/Users/tyleonha/Code/PowerShell/Misc/%E6%B5%8B%E8%AF%95.ps1").ToString()
file://%2FC%3A%2FUsers%2Ftyleonha%2FCode%2FPowerShell%2FMisc%2F测试.ps1/C%3A/Users/tyleonha/Code/PowerShell/Misc/测试.ps1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions