Skip to content

Commit

Permalink
Resolved #2595: No need to normalize "-" chars.
Browse files Browse the repository at this point in the history
  • Loading branch information
hikalkan committed Nov 14, 2017
1 parent b8409f4 commit ac1fad0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
7 changes: 1 addition & 6 deletions src/Abp/Resources/Embedded/EmbeddedFilePathHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ public static string NormalizePath(string fullPath)
}
}

return NormalizeChars(fileName) + extension;
}

private static string NormalizeChars(string fileName)
{
return fileName.Replace(".", "/").Replace("-", "_");
return fileName + extension;
}
}
}
8 changes: 1 addition & 7 deletions src/Abp/Resources/Embedded/EmbeddedResourceSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,12 @@ private string ConvertToRelativePath(string resourceName)
return resourceName;
}

var folder = pathParts.Take(pathParts.Length - 2).Select(NormalizeFolderName).JoinAsString("/");
var folder = pathParts.Take(pathParts.Length - 2).JoinAsString("/");
var fileName = pathParts[pathParts.Length - 2] + "." + pathParts[pathParts.Length - 1];

return folder + "/" + fileName;
}

private static string NormalizeFolderName(string pathPart)
{
//TODO: Implement all rules of .NET
return pathPart.Replace('-', '_');
}

private static string CalculateFileName(string filePath)
{
if (!filePath.Contains("/"))
Expand Down
10 changes: 10 additions & 0 deletions test/Abp.Tests/Resources/Embedded/EmbeddedResourceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,15 @@ public void Should_Define_And_Get_Embedded_Resources()
Assert.True(resource.Assembly == GetType().GetAssembly());
Assert.True(resource.Content.Length > 0);
}

[Fact]
public void Should_Get_Embedded_Resource_With_Dash_In_Name()
{
var resource = _embeddedResourceManager.GetResource("/MyApp/MyResources/js/MyScriptFile1.js");

resource.ShouldNotBeNull();
Assert.True(resource.Assembly == GetType().GetAssembly());
Assert.True(resource.Content.Length > 0);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* This file is just a sample to use in tests */
alert('hello world 2!');

0 comments on commit ac1fad0

Please sign in to comment.