Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IOUtil.unrollPaths for http paths with query parameters #1688

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bleep, bloop