Skip to content

[Uri] Support WHATWG URL standard #29839

@hyspace

Description

@hyspace

Hi all,

We noticed that System.Private.Uri is not following the WHATWG living standard of URL, which results in some different parsing result comparing to major browsers.

For example:

Uri.TryCreate("http:////example.com///", UriKind.Absolute, out var uri)

will return false, but the Standard is considering http:////example.com/// as valid input and will correct it to http://example.com///.
If you try this example URL in any major browser you will get same result as Standard defined.

This type of difference made it difficult to use .NET and C# in web browsing related scenarios, like Crawlers or HTML Parsers.

The AngleSharp project is one of the most commonly used C# HTML Parser. Today, they have to implement their own Url Class to be able to parse URL in the way Stardard defined. I think it will be much better if C# core library can handle it correctly.

Alone with the Standard, there is a set of test cases about URL for browsers or web developers to verify their implementation of the Standard. Today System.Private.Uri is failing many tests from it, including the example above.

Is there any plan to let System.Private.Uri following WHATWG URL Standard?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions