mirror of
https://github.com/Sonarr/Sonarr
synced 2025-01-02 21:24:56 +00:00
Fixed HttpUri parsing of domain names with underscores.
This commit is contained in:
parent
f8be5c9cb9
commit
1b6d6c26d5
2 changed files with 11 additions and 4 deletions
|
@ -7,6 +7,13 @@ namespace NzbDrone.Common.Test.Http
|
|||
{
|
||||
public class HttpUriFixture : TestBase
|
||||
{
|
||||
[TestCase("abc://my_host.com:8080/root/api/")]
|
||||
public void should_parse(string uri)
|
||||
{
|
||||
var newUri = new HttpUri(uri);
|
||||
newUri.FullUri.Should().Be(uri);
|
||||
}
|
||||
|
||||
[TestCase("", "", "")]
|
||||
[TestCase("/", "", "/")]
|
||||
[TestCase("base", "", "base")]
|
||||
|
@ -77,7 +84,7 @@ namespace NzbDrone.Common.Test.Http
|
|||
public void should_combine_relative_path(string basePath, string relativePath, string expected)
|
||||
{
|
||||
var newUri = new HttpUri(basePath).CombinePath(relativePath);
|
||||
|
||||
|
||||
newUri.FullUri.Should().Be(expected);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace NzbDrone.Common.Http
|
|||
{
|
||||
public class HttpUri : IEquatable<HttpUri>
|
||||
{
|
||||
private static readonly Regex RegexUri = new Regex(@"^(?:(?<scheme>[a-z]+):)?(?://(?<host>[-A-Z0-9.]+)(?::(?<port>[0-9]{1,5}))?)?(?<path>(?:(?:(?<=^)|/)[^/?#\r\n]+)+/?|/)?(?:\?(?<query>[^#\r\n]*))?(?:\#(?<fragment>.*))?$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex RegexUri = new Regex(@"^(?:(?<scheme>[a-z]+):)?(?://(?<host>[-_A-Z0-9.]+)(?::(?<port>[0-9]{1,5}))?)?(?<path>(?:(?:(?<=^)|/)[^/?#\r\n]+)+/?|/)?(?:\?(?<query>[^#\r\n]*))?(?:\#(?<fragment>.*))?$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
private readonly string _uri;
|
||||
public string FullUri => _uri;
|
||||
|
@ -168,7 +168,7 @@ namespace NzbDrone.Common.Http
|
|||
{
|
||||
return basePath.Substring(0, baseSlashIndex) + "/" + relativePath;
|
||||
}
|
||||
|
||||
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,7 @@ namespace NzbDrone.Common.Http
|
|||
{
|
||||
return new HttpUri(baseUrl.Scheme, baseUrl.Host, baseUrl.Port, CombineRelativePath(baseUrl.Path, relativeUrl.Path), relativeUrl.Query, relativeUrl.Fragment);
|
||||
}
|
||||
|
||||
|
||||
return new HttpUri(baseUrl.Scheme, baseUrl.Host, baseUrl.Port, baseUrl.Path, relativeUrl.Query, relativeUrl.Fragment);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue