#510 parsing bug with Uri + default port
This commit is contained in:
parent
f3551eace0
commit
a8d540c272
@ -559,5 +559,14 @@ namespace Flurl.Test.UrlBuilder
|
||||
Assert.IsInstanceOf<Url>(url);
|
||||
Assert.AreEqual("http://mysite.com", url.ToString());
|
||||
}
|
||||
|
||||
[Test] // https://github.com/tmenier/Flurl/issues/510
|
||||
public void uri_with_default_port_parses_correctly() {
|
||||
var originalString = "https://someurl.net:443/api/somepath";
|
||||
var uri = new Uri(originalString);
|
||||
var url = new Url(uri);
|
||||
Assert.AreEqual(443, url.Port);
|
||||
Assert.AreEqual(originalString, url.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ namespace Flurl
|
||||
_scheme = uri.Scheme;
|
||||
_userInfo = uri.UserInfo;
|
||||
_host = uri.Host;
|
||||
_port = uri.Authority.OrdinalEndsWith($":{uri.Port}") ? uri.Port : (int?)null; // don't default Port if not included
|
||||
_port = _baseUrl.OrdinalStartsWith($"{Root}:{uri.Port}") ? uri.Port : (int?)null; // don't default Port if not included explicitly
|
||||
_pathSegments = new List<string>();
|
||||
if (uri.AbsolutePath.Length > 0 && uri.AbsolutePath != "/")
|
||||
AppendPathSegment(uri.AbsolutePath);
|
||||
|
Loading…
x
Reference in New Issue
Block a user