Skip to content

Commit

Permalink
Case insensitive URI schema
Browse files Browse the repository at this point in the history
  • Loading branch information
w3stling committed Sep 24, 2024
1 parent 696238e commit 4434fbb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,8 @@ public CompletableFuture<Stream<I>> readAsync(String url) {

try {
var uri = URI.create(url);
if ("file".equals(uri.getScheme())) {
if ("file".equalsIgnoreCase(uri.getScheme())) {
// Read from file
return CompletableFuture.supplyAsync(() -> {
try {
return read(new FileInputStream(uri.getPath()));
Expand All @@ -511,10 +512,12 @@ public CompletableFuture<Stream<I>> readAsync(String url) {
}
});
} else {
// Read from http or https
return sendAsyncRequest(url).thenApply(processResponse());
}
} catch (IllegalArgumentException e) {
return CompletableFuture.supplyAsync(() -> {
// Read feed data provided as a string
var inputStream = new ByteArrayInputStream(url.getBytes(StandardCharsets.UTF_8));
return read(inputStream);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -822,12 +822,19 @@ void atomFeedWithCategory() {
}

@Test
void readFromFileUri() throws IOException, URISyntaxException {
void readFromFileUriLowerCase() throws IOException, URISyntaxException {
var uri = getFileUri("rss-feed.xml");
var items = new RssReader().read(uri).collect(Collectors.toList());
assertEquals(20, items.size());
}

@Test
void readFromFileUriUpperCase() throws IOException, URISyntaxException {
var uri = getFileUri("rss-feed.xml").replace("file:", "FILE:");
var items = new RssReader().read(uri).collect(Collectors.toList());
assertEquals(20, items.size());
}

@Test
void readFromMultipleFileUri() throws URISyntaxException {
var uris = List.of(
Expand Down

0 comments on commit 4434fbb

Please sign in to comment.