Skip to content

Commit

Permalink
Fix IOUtil.unrollPaths for http paths with query parameters (#1688)
Browse files Browse the repository at this point in the history
* Stop treating query parameters in an http path as part of the file extension
  • Loading branch information
lbergelson authored Oct 13, 2023
1 parent 6d1a796 commit 5f0d484
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/htsjdk/samtools/util/IOUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ public static List<Path> unrollPaths(final Collection<Path> inputs, final String

while (!stack.empty()) {
final Path p = stack.pop();
final String name = p.toString();
final String name = p.getFileName().toString();
boolean matched = false;

for (final String ext : extensions) {
Expand Down
10 changes: 9 additions & 1 deletion src/test/java/htsjdk/samtools/util/IOUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ public void testAssertDirectoryIsWritableFile(final File file, final boolean wri

static final String level1 = "Level1.fofn";
static final String level2 = "Level2.fofn";
static final String fofnHttpQueryParams = "FofnWithHttpQueryParams.fofn";

@DataProvider
public Object[][] fofnData() throws IOException {
Expand All @@ -460,11 +461,18 @@ public Object[][] fofnData() throws IOException {
Path fofnPath2 = inMemoryFileSystem.getPath(level2);
Files.copy(TEST_DATA_DIR.resolve(level2), fofnPath2);

Path withHttpPath = inMemoryFileSystem.getPath(fofnHttpQueryParams);
Files.copy(TEST_DATA_DIR.resolve(fofnHttpQueryParams), withHttpPath);

return new Object[][]{
{TEST_DATA_DIR + "/" + level1, new String[]{".vcf", ".vcf.gz"}, 2},
{TEST_DATA_DIR + "/" + level2, new String[]{".vcf", ".vcf.gz"}, 4},
{fofnPath1.toUri().toString(), new String[]{".vcf", ".vcf.gz"}, 2},
{fofnPath2.toUri().toString(), new String[]{".vcf", ".vcf.gz"}, 4}
{fofnPath2.toUri().toString(), new String[]{".vcf", ".vcf.gz"}, 4},
//test http links with query parameters are handled correctly
//test disabled until NIO http provider is integrated
//see https://github.com/samtools/htsjdk/issues/1689
//{withHttpPath.toUri().toString(), new String[]{".vcf", ".vcf.gz"}, 4}
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
src/test/resources/htsjdk/samtools/io/Level1.fofn
http://www.example.com/blurg.vcf
http://www.example.com/blurg.vcf?huh=bleep,bloop

0 comments on commit 5f0d484

Please sign in to comment.