Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions PreMailer.Net/PreMailer.Net.Tests/ImportRuleCssSourceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,24 @@ public void ItShould_HandleCircularImports_WithoutInfiniteLoop()
_webDownloader.Verify(w => w.DownloadString(It.Is<Uri>(u => u.ToString() == "https://a.com/circular2.css")), Times.Once);
}

[Fact]
public void ItShould_PreservePortNumber_WhenResolvingRelativeImports()
{
var baseUri = new Uri("https://localhost:8080/styles/main.css");
var css = "@import \"variables.css\";";
var variablesCss = "body { color: red; }";

_webDownloader
.Setup(w => w.DownloadString(It.Is<Uri>(u => u.ToString() == "https://localhost:8080/styles/variables.css")))
.Returns(variablesCss);

var sut = new ImportRuleCssSource();

var result = sut.GetCss(baseUri, css).ToList();

_webDownloader.Verify(w => w.DownloadString(It.Is<Uri>(u => u.ToString() == "https://localhost:8080/styles/variables.css")), Times.Once);
}

private string CreateCss(IEnumerable<string> imports)
{
var builder = new StringBuilder();
Expand Down
1 change: 0 additions & 1 deletion PreMailer.Net/PreMailer.Net/Sources/ImportRuleCssSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ private static Uri GetBaseUri(Uri downloadUri)
{
var baseUrl = new UriBuilder(downloadUri)
{
Port = -1 /* Excludes the port number */,
Query = string.Empty
};

Expand Down