Skip to content

Commit 54578d2

Browse files
committed
ModuleSearchResult: improve location reporting
The getLocation() method typically returns strings with "file://" prefix. Let's strip that, so the subsequent baseDir logic works.
1 parent 8b5eb0b commit 54578d2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/org/scijava/search/module/ModuleSearchResult.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ public Map<String, String> properties() {
102102
// -- Helper methods --
103103

104104
private String getLocation() {
105-
final String path = info.getLocation();
106-
if (path != null && baseDir != null && path.startsWith(baseDir)) {
105+
String path = info.getLocation();
106+
if (path == null) return null;
107+
if (path.startsWith("file:/")) path = path.replaceFirst("file:/+", "/");
108+
if (baseDir != null && path.startsWith(baseDir)) {
107109
if (path.length() == baseDir.length()) return "";
108-
return path.substring(baseDir.length() + 1);
110+
path = path.substring(baseDir.length() + 1);
109111
}
110112
return path;
111113
}

0 commit comments

Comments
 (0)