Skip to content
Snippets Groups Projects
Commit ff1c5ccb authored by Vincent Massol's avatar Vincent Massol
Browse files

XWIKI-9376: Short URL don't work anymore

* Fix regression introduced by previous commits
parent 3cfda0ff
No related branches found
No related tags found
No related merge requests found
......@@ -172,17 +172,18 @@ private void normalizeSegments(ExtendedURL url, boolean isActuallyPathBased)
// Thus removing 2 segments means keeping: action/space/page
if (isActuallyPathBased) {
url.getSegments().remove(0);
}
// In Domain based, we still need to remove one segment since the first segment will contain the type
// (e.g. "bin"). However, since we want to support Short URLs and allow the user to not specify the type
// prefix, we only remove the segment if its value is of the configured value.
// Note that we also always support "bin" in order to make it easy for the user so that he doesn't have to
// change all the URLs everywhere (like the error page URL in web.xml, etc).
String entityPathPrefix = this.configuration.getEntityPathPrefix();
String firstSegment = url.getSegments().get(0);
if (firstSegment.equals(entityPathPrefix) || firstSegment.equals("bin")) {
url.getSegments().remove(0);
} else {
// In Domain based, we still need to remove one segment since the first segment will contain the type
// (e.g. "bin"). However, since we want to support Short URLs and allow the user to not specify the type
// prefix, we only remove the segment if its value is of the configured value.
// Note that we also always support "bin" in order to make it easy for the user so that he doesn't have to
// change all the URLs everywhere (like the error page URL in web.xml, etc).
String entityPathPrefix = this.configuration.getEntityPathPrefix();
String firstSegment = url.getSegments().get(0);
if (firstSegment.equals(entityPathPrefix) || firstSegment.equals("bin")) {
url.getSegments().remove(0);
}
}
}
......
......@@ -159,6 +159,17 @@ public void createURLWhenUsingBinEvenThoughPathConfiguredAsEntity() throws Excep
EntityType.DOCUMENT);
}
@Test
public void createURLWhenInPathBasedSubWiki() throws Exception
{
WikiReferenceExtractor wikiReferenceExtractor = this.mocker.getInstance(WikiReferenceExtractor.class);
when(wikiReferenceExtractor.extract(any(ExtendedURL.class))).thenReturn(
new ImmutablePair<WikiReference, Boolean>(new WikiReference("somewiki"), true));
EntityReference reference = buildEntityReference("somewiki", "space", "page");
testCreateURL("http://localhost/wiki/somewiki/view/space/page", "view",
reference, reference, EntityType.DOCUMENT);
}
private XWikiURL testCreateURL(String testURL, String expectedAction, EntityReference expectedReference,
EntityReference returnedReference, EntityType expectedEntityType) throws Exception
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment