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

File resolver should handle file ending with slash #5334

Merged
merged 2 commits into from
Sep 29, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ public void close() throws IOException {
}

public File resolveFile(String fileName) {
int idx = fileName.length() - 1;
if (idx >= 0 && fileName.charAt(idx) == '/') {
fileName = fileName.substring(0, idx);
}
return resolveFile2(fileName);
}

public File resolveFile2(String fileName) {
// First look for file with that name on disk
File file = new File(fileName);
boolean absolute = file.isAbsolute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,12 @@ public void testReadFileInDirThenReadDirMultipleLevels() {
assertEquals(new HashSet<>(Arrays.asList("b", "b.txt")), names);
}

@Test
public void testBugEndWithSlash() {
FileResolver resolver = ((VertxInternal) vertx).fileResolver();
File buff = resolver.resolveFile("tree/");
}

@Test
public void testReadFileInDirThenReadDirMultipleLevelsMissingResource() {
Buffer buff = vertx.fileSystem().readFileBlocking("tree/a/b/c.txt");
Expand Down
Loading