Skip to content

Commit dec141d

Browse files
committed
Refactor PDF URL detection using FileUtil.isPDFFile
1 parent 96a4f4a commit dec141d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/main/java/org/jabref/gui/externalfiles/ImportHandler.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,15 @@ public List<BibEntry> handleStringData(String data) throws FetcherException {
405405
}
406406
LOGGER.trace("Checking if URL is a PDF: {}", data);
407407

408-
if (URLUtil.isURL(data) && data.toLowerCase().endsWith(".pdf")) {
409-
try {
410-
return handlePdfUrl(data);
411-
} catch (IOException ex) {
412-
LOGGER.error("Could not handle PDF URL", ex);
413-
return List.of();
408+
if (URLUtil.isURL(data)) {
409+
String fileName = data.substring(data.lastIndexOf('/') + 1);
410+
if (FileUtil.isPDFFile(Path.of(fileName))) {
411+
try {
412+
return handlePdfUrl(data);
413+
} catch (IOException ex) {
414+
LOGGER.error("Could not handle PDF URL", ex);
415+
return List.of();
416+
}
414417
}
415418
}
416419

0 commit comments

Comments
 (0)