Skip to content

Commit ca94d70

Browse files
tulinkryVladimir Kotal
authored andcommitted
adding a forced redirect for url /xref to /xref/ (#1588)
fixes #1544
1 parent 324429b commit ca94d70

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/org/opensolaris/opengrok/web/PageConfig.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import java.util.Arrays;
3939
import java.util.Collections;
4040
import java.util.EnumSet;
41-
import java.util.HashSet;
4241
import java.util.List;
4342
import java.util.Set;
4443
import java.util.SortedSet;
@@ -1173,11 +1172,21 @@ public File findDataFile() {
11731172
*/
11741173
public String getDirectoryRedirect() {
11751174
if (isDir()) {
1175+
getPrefix();
1176+
/**
1177+
* Redirect /xref -> /xref/
1178+
*/
1179+
if (prefix == Prefix.XREF_P
1180+
&& getUriEncodedPath().isEmpty()
1181+
&& !req.getRequestURI().endsWith("/")) {
1182+
return req.getContextPath() + Prefix.XREF_P + '/';
1183+
}
1184+
11761185
if (path.length() == 0) {
11771186
// => /
11781187
return null;
11791188
}
1180-
getPrefix();
1189+
11811190
if (prefix != Prefix.XREF_P && prefix != Prefix.HIST_L
11821191
&& prefix != Prefix.RSS_P) {
11831192
// if it is an existing dir perhaps people wanted dir xref

0 commit comments

Comments
 (0)