mirror of https://github.com/Ombi-app/Ombi
Fixes issue #3195
The new string extension method ToHttpsUrl ensures that URLs starting with "https" are no longer turned into "httpss" The commit also replaces all occurances of the error prone .Replace("http", "https") in the whole solution.pull/3199/head
parent
9940156fea
commit
ab8e5cca7e
@ -0,0 +1,44 @@
|
|||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Ombi.Helpers.Tests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class StringHelperTests
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void ToHttpsUrl_ShouldReturnsHttpsUrl_HttpUrl()
|
||||||
|
{
|
||||||
|
var sourceUrl = "http://www.test.url";
|
||||||
|
var expectedUrl = "https://www.test.url";
|
||||||
|
|
||||||
|
Assert.AreEqual(expectedUrl, sourceUrl.ToHttpsUrl(), "Should return the source URL as https");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ToHttpsUrl_ShouldReturnsUnchangedUrl_HttpsUrl()
|
||||||
|
{
|
||||||
|
var sourceUrl = "https://www.test.url";
|
||||||
|
var expectedUrl = "https://www.test.url";
|
||||||
|
|
||||||
|
Assert.AreEqual(expectedUrl, sourceUrl.ToHttpsUrl(), "Should return the unchanged https URL");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ToHttpsUrl_ShouldReturnsUnchangedUrl_NonHttpUrl()
|
||||||
|
{
|
||||||
|
var sourceUrl = "ftp://www.test.url";
|
||||||
|
var expectedUrl = "ftp://www.test.url";
|
||||||
|
|
||||||
|
Assert.AreEqual(expectedUrl, sourceUrl.ToHttpsUrl(), "Should return the unchanged non-http URL");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ToHttpsUrl_ShouldReturnsUnchangedUrl_InvalidUrl()
|
||||||
|
{
|
||||||
|
var sourceUrl = "http:/www.test.url";
|
||||||
|
var expectedUrl = "http:/www.test.url";
|
||||||
|
|
||||||
|
Assert.AreEqual(expectedUrl, sourceUrl.ToHttpsUrl(), "Should return the unchanged invalid URL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue