Skip to content

Commit

Permalink
Fix base URI matching again to account for path encoding issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jgustie committed Oct 17, 2018
1 parent f2701ae commit b0c6547
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
Expand Down Expand Up @@ -265,13 +267,17 @@ private static String algorithmName(String signatureType) {
* this reduces the overhead of heavy use.
*/
public static Predicate<LegacyScanNode> isBase(String baseDir) {
String baseUri = HID.valueOf("file:" + baseDir).toUriString();
String baseArchiveUri = "file:" + beforeLast(baseDir, '/') + "/";
String baseName = afterLast(baseDir, '/');
return scanNode -> Objects.equals(scanNode.uri, baseUri)
|| (Objects.equals("/", scanNode.path)
&& Objects.equals(scanNode.archiveUri, baseArchiveUri)
&& Objects.equals(scanNode.name, baseName));
try {
String baseUri = HID.valueOf(new URI("file", null, baseDir, null).toString()).toUriString();
String baseArchiveUri = "file:" + beforeLast(baseDir, '/') + "/";
String baseName = afterLast(baseDir, '/');
return scanNode -> Objects.equals(scanNode.uri, baseUri)
|| (Objects.equals("/", scanNode.path)
&& Objects.equals(scanNode.archiveUri, baseArchiveUri)
&& Objects.equals(scanNode.name, baseName));
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
}

Expand Down

0 comments on commit b0c6547

Please sign in to comment.