Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
5.1.0.3
-
None
Description
When creating a page link to the Index page with a context, Tapestry creates a link with two slashes after the context path
Example: /app//123
Because LinkImpl uses RequestPathOptimizer.optimizePath() inside the methode toUri() the url is optimized to 123. So the link to the Index page will work.
But when you write a test for a page Foo (which contains a link to Index page) with PageTester, the test will fail because RequestPathOptimizer does not cut the url. The optimizer skips the optimization because in tests you can not use SymbolConstants.FORCE_ABSOLUTE_URIS = false. PagesTestes throws an exception if a path does not start with context path.
<t:pagelink page="Index" context="123">...</t:pagelink>
To fix the problem we have to check inside ComponentEventLinkEncoderImpl.appendContext() if the url ends with a slash.
public void appendContext(EventContext context, StringBuilder builder)
{
String encoded = contextPathEncoder.encodeIntoPath(context);
if (encoded.length() > 0)
{
if(!encoded.endsWith(SLASH))
builder.append(encoded);
}
}