Skip to content

Commit 7cb64f3

Browse files
author
Vladimir Kotal
authored
JSTL vs Paths (#2814)
fixes #2806
1 parent f275ac4 commit 7cb64f3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/web/PageConfig.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import java.net.URISyntaxException;
3838
import java.net.URLDecoder;
3939
import java.nio.charset.StandardCharsets;
40+
import java.nio.file.Paths;
4041
import java.security.InvalidParameterException;
4142
import java.util.ArrayList;
4243
import java.util.Arrays;
@@ -1750,4 +1751,13 @@ public boolean isNotModified(HttpServletRequest request, HttpServletResponse res
17501751
response.setHeader(HttpHeaders.ETAG, currentEtag);
17511752
return false;
17521753
}
1754+
1755+
/**
1756+
* @param root root path
1757+
* @param path path
1758+
* @return path relative to root
1759+
*/
1760+
public static String getRelativePath(String root, String path) {
1761+
return Paths.get(root).relativize(Paths.get(path)).toString();
1762+
}
17531763
}

opengrok-web/src/main/webapp/WEB-INF/tags/repository.tag

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ CDDL HEADER END
1919
Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2020
Portions Copyright (c) 2019, Krystof Tulinger <[email protected]>.
2121
--%>
22-
<%@ tag import="java.nio.file.Paths" %>
2322
<%@ tag import="org.apache.commons.lang3.ObjectUtils" %>
2423
<%@ tag import="org.opengrok.indexer.web.Prefix" %>
2524
<%@ tag import="org.opengrok.indexer.web.Util" %>
@@ -42,7 +41,7 @@ Portions Copyright (c) 2019, Krystof Tulinger <[email protected]>.
4241

4342
<c:if test="${isSubrepository}">
4443
<c:set var="name"
45-
value="${Paths.get(pageConfig.sourceRootPath).relativize(Paths.get(repositoryInfo.directoryName))}"/>
44+
value="${pageConfig.getRelativePath(pageConfig.sourceRootPath, repositoryInfo.directoryName)}"/>
4645
</c:if>
4746

4847
<c:if test="${isSubrepository && isFirst}">

0 commit comments

Comments
 (0)