Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
Explicitly check if URI is file when checking for an absolute URI
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel15 authored and dougbu committed Sep 1, 2015
1 parent 55fc7de commit a2e53e8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public string AddFileVersionToPath([NotNull] string path)
}

Uri uri;
if (Uri.TryCreate(resolvedPath, UriKind.Absolute, out uri))
if (Uri.TryCreate(resolvedPath, UriKind.Absolute, out uri) && !uri.IsFile)
{
// Don't append version if the path is absolute.
return path;
Expand Down
14 changes: 1 addition & 13 deletions test/Microsoft.AspNet.Mvc.FunctionalTests/HtmlGenerationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ public class HtmlGenerationTest
[InlineData("AttributesWithBooleanValues", null)]
public async Task HtmlGenerationWebSite_GeneratesExpectedResults(string action, string antiforgeryPath)
{
// This uses FileVersionProvider which uses Uri.TryCreate - https://github.com/aspnet/External/issues/21
if (TestPlatformHelper.IsMono && (action == "Link" || action == "Script" || action == "Image"))
{
return;
}

// Arrange
var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
var client = server.CreateClient();
Expand Down Expand Up @@ -124,12 +118,6 @@ public async Task HtmlGenerationWebSite_GeneratesExpectedResults(string action,
[InlineData("AttributesWithBooleanValues", null)]
public async Task HtmlGenerationWebSite_GenerateEncodedResults(string action, string antiforgeryPath)
{
// This uses FileVersionProvider which uses Uri.TryCreate - https://github.com/aspnet/External/issues/21
if (TestPlatformHelper.IsMono && (action == "Link" || action == "Script"))
{
return;
}

// Arrange
var server = TestHelper.CreateServer(_app, SiteName, services =>
{
Expand Down Expand Up @@ -582,4 +570,4 @@ public async Task EditorTemplateWithSpecificModel_RendersWithCorrectMetadata()
Assert.Equal(expected, response);
}
}
}
}
10 changes: 3 additions & 7 deletions test/Microsoft.AspNet.Mvc.TagHelpers.Test/ImageTagHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ public void PreservesOrderOfSourceAttributesWhenRun()
}
}

[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/21
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[Fact]
public void RendersImageTag_AddsFileVersion()
{
// Arrange
Expand Down Expand Up @@ -209,9 +207,7 @@ public void RendersImageTag_DoesNotAddFileVersion()
Assert.Equal("/images/test-image.png", srcAttribute.Value);
}

[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/21
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[Fact]
public void RendersImageTag_AddsFileVersion_WithRequestPathBase()
{
// Arrange
Expand Down Expand Up @@ -337,4 +333,4 @@ private static IUrlHelper MakeUrlHelper()
return urlHelper.Object;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers.Internal
{
public class FileVersionProviderTest
{
[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/21
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[Theory]
[InlineData("/hello/world", "/hello/world?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk")]
[InlineData("/hello/world?q=test", "/hello/world?q=test&v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk")]
[InlineData("/hello/world?q=foo&bar", "/hello/world?q=foo&bar&v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk")]
Expand All @@ -42,9 +40,7 @@ public void AddsVersionToFiles_WhenCacheIsAbsent(string filePath, string expecte
}

// Verifies if the stream is closed after reading.
[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/21
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[Fact]
public void AddsVersionToFiles_DoesNotLockFileAfterReading()
{
// Arrange
Expand Down Expand Up @@ -75,9 +71,7 @@ public void AddsVersionToFiles_DoesNotLockFileAfterReading()
Assert.Throws<ObjectDisposedException>(() => fileVersionProvider.AddFileVersionToPath("/hello/world"));
}

[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/21
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[Theory]
[InlineData("/testApp/hello/world", true, "/testApp")]
[InlineData("/testApp/foo/bar/hello/world", true, "/testApp/foo/bar")]
[InlineData("/test/testApp/hello/world", false, "/testApp")]
Expand All @@ -100,9 +94,7 @@ public void AddsVersionToFiles_PathContainingAppName(
Assert.Equal(filePath + "?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", result);
}

[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/21
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[Fact]
public void DoesNotAddVersion_IfFileNotFound()
{
// Arrange
Expand All @@ -120,9 +112,7 @@ public void DoesNotAddVersion_IfFileNotFound()
Assert.Equal("http://contoso.com/hello/world", result);
}

[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/21
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[Fact]
public void ReturnsValueFromCache()
{
// Arrange
Expand All @@ -140,9 +130,7 @@ public void ReturnsValueFromCache()
Assert.Equal("FromCache", result);
}

[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/21
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[Theory]
[InlineData("/hello/world", "/hello/world", null)]
[InlineData("/testApp/hello/world", "/hello/world", "/testApp")]
public void SetsValueInCache(string filePath, string watchPath, string requestPathBase)
Expand Down Expand Up @@ -235,4 +223,4 @@ private static PathString GetRequestPathBase(string requestPathBase = null)
return new PathString(requestPathBase);
}
}
}
}
14 changes: 4 additions & 10 deletions test/Microsoft.AspNet.Mvc.TagHelpers.Test/LinkTagHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -678,9 +678,7 @@ public void RendersLinkTagsForGlobbedHrefResults_UsingProvidedEncoder()
output.PostElement.GetContent());
}

[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/21
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[Fact]
public void RendersLinkTags_AddsFileVersion()
{
// Arrange
Expand Down Expand Up @@ -720,9 +718,7 @@ public void RendersLinkTags_AddsFileVersion()
Assert.Equal("/css/site.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["href"].Value);
}

[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/21
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[Fact]
public void RendersLinkTags_AddsFileVersion_WithRequestPathBase()
{
// Arrange
Expand Down Expand Up @@ -762,9 +758,7 @@ public void RendersLinkTags_AddsFileVersion_WithRequestPathBase()
Assert.Equal("/bar/css/site.css?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["href"].Value);
}

[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/21
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[Fact]
public void RendersLinkTags_GlobbedHref_AddsFileVersion()
{
// Arrange
Expand Down Expand Up @@ -914,4 +908,4 @@ private static IUrlHelper MakeUrlHelper()
return urlHelper.Object;
}
}
}
}
18 changes: 5 additions & 13 deletions test/Microsoft.AspNet.Mvc.TagHelpers.Test/ScriptTagHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,7 @@ public async Task RendersScriptTagsForGlobbedSrcResults_UsesProvidedEncoder()
Assert.Equal("<script src=\"HtmlEncode[[/common.js]]\"></script>", output.PostElement.GetContent());
}

[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/21
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[Fact]
public async Task RenderScriptTags_WithFileVersion()
{
// Arrange
Expand Down Expand Up @@ -772,9 +770,7 @@ public async Task RenderScriptTags_WithFileVersion()
Assert.Equal("/js/site.js?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["src"].Value);
}

[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/21
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[Fact]
public async Task RenderScriptTags_WithFileVersion_AndRequestPathBase()
{
// Arrange
Expand Down Expand Up @@ -811,9 +807,7 @@ public async Task RenderScriptTags_WithFileVersion_AndRequestPathBase()
Assert.Equal("/bar/js/site.js?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk", output.Attributes["src"].Value);
}

[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/21
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[Fact]
public async Task RenderScriptTags_FallbackSrc_WithFileVersion()
{
// Arrange
Expand Down Expand Up @@ -857,9 +851,7 @@ public async Task RenderScriptTags_FallbackSrc_WithFileVersion()
"<\\/script>\"));</script>", output.PostElement.GetContent());
}

[ConditionalTheory]
// Mono issue - https://github.com/aspnet/External/issues/21
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
[Fact]
public async Task RenderScriptTags_GlobbedSrc_WithFileVersion()
{
// Arrange
Expand Down Expand Up @@ -1012,4 +1004,4 @@ private static IUrlHelper MakeUrlHelper()
return urlHelper.Object;
}
}
}
}

0 comments on commit a2e53e8

Please sign in to comment.