Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug when new url is missing trailing slash #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private static void BuildPath(

builder.Append(path);

if (hasAppendSegment && !pathHasTrailingSlash)
if (hasAppendSegment && !path.EndsWith("/"))
{
builder.Append('/');
}
Expand Down
19 changes: 19 additions & 0 deletions tests/Geta.NotFoundHandler.Tests/CustomRedirectCollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,5 +399,24 @@ public void Find_decodes_plus_sign_correctly()

Assert.Equal(expected, actual.NewUrl);
}

/// <summary>
/// https://github.com/Geta/geta-notfoundhandler/issues/137
/// </summary>
[Fact]
public void Find_does_add_slash_when_new_url_is_missing_trailing_slash()
{
var collection = new CustomRedirectCollection
{
new CustomRedirect("/content", "/legacy"),
};

var urlToFind = "/content/file/";
var expected = "/legacy/file/";

var actual = collection.Find(urlToFind.ToUri());

Assert.Equal(expected, actual.NewUrl);
}
}
}
Loading