Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

WICKET-5123 render url as "." instead of "./."

  • Loading branch information...
commit bf13599b1cc55066840a0d821eec583310540f14 1 parent c70a52a
svenmeier authored
View
21 wicket-core/src/test/java/org/apache/wicket/request/cycle/UrlRendererTest.java
@@ -149,7 +149,7 @@ public void test10()
public void test11()
{
UrlRenderer r1 = new UrlRenderer(new MockWebRequest(Url.parse("a")));
- assertEquals("./.", r1.renderUrl(Url.parse("")));
+ assertEquals(".", r1.renderUrl(Url.parse("")));
}
/**
@@ -470,6 +470,23 @@ public void renderFullUrlAsRelativeToBaseUrlWithFirstSegmentsEqualToTheFilterPat
}
/**
+ * https://issues.apache.org/jira/browse/WICKET-5123
+ */
+ @Test
+ public void renderHomeUrl()
+ {
+ Url baseUrl = Url.parse("login");
+
+ MockWebRequest request = new MockWebRequest(baseUrl);
+ UrlRenderer renderer = new UrlRenderer(request);
+
+ Url homeUrl = Url.parse("");
+ String encodedRelativeUrl = renderer.renderUrl(homeUrl);
+
+ assertEquals(".", encodedRelativeUrl);
+ }
+
+ /**
* https://issues.apache.org/jira/browse/WICKET-5065
*/
@Test
@@ -526,7 +543,7 @@ public void renderAbsoluteWithoutSchemeWithPort()
@Test
public void removeCommonPrefixesWicket5073()
{
- Url baseUrl = new Url(Arrays.asList(""), Arrays.<Url.QueryParameter>asList());
+ Url baseUrl = new Url(Arrays.asList(""), Arrays.<Url.QueryParameter> asList());
MockWebRequest request = new MockWebRequest(baseUrl);
request.setContextPath("/qs");
View
5 wicket-request/src/main/java/org/apache/wicket/request/UrlRenderer.java
@@ -283,7 +283,7 @@ public String renderRelativeUrl(final Url url)
String renderedUrl = new Url(newSegments, url.getQueryParameters()).toString();
// sanitize start
- if (!renderedUrl.startsWith(".."))
+ if (!renderedUrl.startsWith("..") && !renderedUrl.equals("."))
{
// WICKET-4260
renderedUrl = "./" + renderedUrl;
@@ -363,7 +363,8 @@ protected boolean shouldRenderAsFull(final Url url)
{
return true;
}
- if (url.isAbsolute()) {
+ if (url.isAbsolute())
+ {
// do not relativize urls like "/a/b"
return true;
}
Please sign in to comment.
Something went wrong with that request. Please try again.