Skip to content

Commit

Permalink
fix checking asset file ext
Browse files Browse the repository at this point in the history
  • Loading branch information
saleem-hadad committed Sep 19, 2022
1 parent 0c5be6a commit 04b2c52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static bool IsDocumentationUrl(this PathString pathString) =>
pathString.Value != null && pathString.Value.StartsWith("/docs/") && ! pathString.IsDocumentationAssets();

public static bool IsDocumentationAssets(this PathString pathString) =>
pathString.Value != null && Regex.IsMatch(pathString.Value, "^(/+\\w{0,}){0,}\\.\\w{1,}$", RegexOptions.IgnoreCase);
pathString.Value != null && Regex.IsMatch(pathString.Value, "^.+\\..+$", RegexOptions.IgnoreCase);

public static string ResolveRelativeUrl(this PathString pathString, string url) =>
string.IsNullOrEmpty(pathString) || ! pathString.HasValue || pathString.Value.EndsWith("/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ public class PathStringExtensionsTests
{
[Theory]
[InlineData("", false)]
[InlineData("/", false)]
[InlineData("/docs", false)]
[InlineData("/docs/file", false)]
[InlineData("/docs/overview", false)]
[InlineData("/docs/images/image", false)]
[InlineData("/32rt34", false)]
[InlineData("/3$2\\3232", false)]
[InlineData("/docs/images/image.png", true)]
[InlineData("/docs/app.css", true)]
[InlineData("/app.js", true)]
[InlineData("/docs/file.something", true)]
[InlineData("/docs/some-file.something", true)]
public void IsDocumentationAssets_Called_ShouldReturnCorrectValue(string path, bool expected)
{
new PathString(path).IsDocumentationAssets().Should().Be(expected);
Expand Down

0 comments on commit 04b2c52

Please sign in to comment.