When passing a Uri to UriBuilder, the resulting builder.Uri has a different OriginalString. Specifically, the port has been added to OriginalString where it was not present originally.
open System
open System.Web
let uri = "http://example.com"
Uri(uri).OriginalString // is "http://example.com"
UriBuilder(Uri(uri)).Uri.OriginalString // is "http://example.com:80/"
This has implications e.g. for serialization of URIs. Newtonsoft.Json seems to use Uri.OriginalString when serializing URIs. This means that after having been through a UriBuilder (e.g. to add path segments), all my URIs come out with ports where they originally had none.
Note that a slash is also added.
This bug exists in at least .NET Core 3.0 and 2.2
When passing a
UritoUriBuilder, the resultingbuilder.Urihas a differentOriginalString. Specifically, the port has been added toOriginalStringwhere it was not present originally.This has implications e.g. for serialization of URIs. Newtonsoft.Json seems to use
Uri.OriginalStringwhen serializing URIs. This means that after having been through aUriBuilder(e.g. to add path segments), all my URIs come out with ports where they originally had none.Note that a slash is also added.
This bug exists in at least .NET Core 3.0 and 2.2