Skip to content
Open
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
24 changes: 24 additions & 0 deletions src/Cassette.Aspnet.UnitTests/PlaceholderRewriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ public void GivenCanRewriteOutput_WhenRewriteOutput_ThenPlaceholderReplacingResp
response.VerifySet(r => r.Filter = It.IsAny<PlaceholderReplacingResponseFilter>());
}

[Fact]
public void GivenWithCharsetCanRewriteOutput_WhenRewriteOutput_ThenPlaceholderReplacingResponseFilterSetForResponse()
{
settings.IsHtmlRewritingEnabled = true;
ContentType("text/html; charset=utf-8");
StatusCode(200);

rewriter.RewriteOutput();

response.VerifySet(r => r.Filter = It.IsAny<PlaceholderReplacingResponseFilter>());
}

[Fact]
public void GivenXhtmlContentType_WhenRewriteOutput_ThenPlaceholderReplacingResponseFilterSetForResponse()
{
Expand All @@ -61,6 +73,18 @@ public void GivenXhtmlContentType_WhenRewriteOutput_ThenPlaceholderReplacingResp
response.VerifySet(r => r.Filter = It.IsAny<PlaceholderReplacingResponseFilter>());
}

[Fact]
public void GivenXhtmlContentTypeWithCharset_WhenRewriteOutput_ThenPlaceholderReplacingResponseFilterSetForResponse()
{
settings.IsHtmlRewritingEnabled = true;
ContentType("application/xhtml+xml; charset=utf-8");
StatusCode(200);

rewriter.RewriteOutput();

response.VerifySet(r => r.Filter = It.IsAny<PlaceholderReplacingResponseFilter>());
}

[Fact]
public void GivenStatusCodeIsRedirect_WhenRewriteOutput_ThenFilterNotInstalled()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Cassette.Aspnet/PlaceholderRewriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ bool CanRewriteOutput(HttpContextBase httpContext)

bool IsHtmlResponse(HttpContextBase httpContext)
{
return httpContext.Response.ContentType == "text/html" ||
httpContext.Response.ContentType == "application/xhtml+xml";
return httpContext.Response.ContentType.StartsWith("text/html") ||
httpContext.Response.ContentType.StartsWith("application/xhtml+xml");
}
}
}