From ce36b8ece14818c08467096cd2bdf09f66a94699 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Thu, 22 Dec 2016 14:53:32 +0100 Subject: [PATCH] Fix #2427: Arxiv fetcher works with prefix --- CHANGELOG.md | 1 + .../sf/jabref/logic/importer/fetcher/ArXiv.java | 4 ++++ .../jabref/logic/importer/fetcher/ArXivTest.java | 14 ++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 844c4ea3e51..dcb6df16429 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We fixed an issue where groups containing brackets were not working properly. Fixes [#2394](https://github.com/JabRef/jabref/issues/2394). - We fixed issues with the [timestamp](http://help.jabref.org/en/TimeStamp) field. However, clearing with the clear button is not possible if timestamp format does not match the current settings. Fixes [#2403](https://github.com/JabRef/jabref/issues/2403). - Fixes [#2406](https://github.com/JabRef/jabref/issues/2406) so that the integrity check filter works again +- The ArXiv fetcher also accepts identifiers that include the "arXiv:" prefix. Fixes [#2427](https://github.com/JabRef/jabref/issues/2427). - Closing of subtrees in the groups panel using "close subtree" is working again. Fixes [#2319](https://github.com/JabRef/jabref/issues/2319). - The proxy settings are now also applied to HTTPS connections. Fixes [#2249](https://github.com/JabRef/jabref/issues/2249). diff --git a/src/main/java/net/sf/jabref/logic/importer/fetcher/ArXiv.java b/src/main/java/net/sf/jabref/logic/importer/fetcher/ArXiv.java index b71e4f555d3..3ea7a277c9f 100644 --- a/src/main/java/net/sf/jabref/logic/importer/fetcher/ArXiv.java +++ b/src/main/java/net/sf/jabref/logic/importer/fetcher/ArXiv.java @@ -107,6 +107,10 @@ private Optional searchForEntry(String searchQuery) throws FetcherEx } private Optional searchForEntryById(String identifier) throws FetcherException { + identifier = identifier.replace("arxiv:", ""); + identifier = identifier.replace("arXiv:", ""); + identifier = identifier.replace("arxiv", ""); + identifier = identifier.replace("arXiv", ""); List entries = queryApi("", Collections.singletonList(identifier), 0, 1); if (entries.size() == 1) { return Optional.of(entries.get(0)); diff --git a/src/test/java/net/sf/jabref/logic/importer/fetcher/ArXivTest.java b/src/test/java/net/sf/jabref/logic/importer/fetcher/ArXivTest.java index a5c914faf4b..44528578f74 100644 --- a/src/test/java/net/sf/jabref/logic/importer/fetcher/ArXivTest.java +++ b/src/test/java/net/sf/jabref/logic/importer/fetcher/ArXivTest.java @@ -75,6 +75,14 @@ public void findByEprint() throws IOException { assertEquals(Optional.of(new URL("http://arxiv.org/pdf/1603.06570v1")), finder.findFullText(entry)); } + @Test + // Test for https://github.com/JabRef/jabref/issues/2427 + public void findByEprintWithPrefix() throws IOException { + entry.setField("eprint", "arXiv:1603.06570"); + + assertEquals(Optional.of(new URL("http://arxiv.org/pdf/1603.06570v1")), finder.findFullText(entry)); + } + @Test public void findByEprintWithUnknownDOI() throws IOException { entry.setField("doi", "10.1529/unknown"); @@ -138,6 +146,12 @@ public void searchEntryByIdWith4Digits() throws Exception { assertEquals(Optional.of(sliceTheoremPaper), finder.performSearchById("1405.2249")); } + @Test + // Test for https://github.com/JabRef/jabref/issues/2427 + public void searchEntryByIdWith4DigitsAndPrefix() throws Exception { + assertEquals(Optional.of(sliceTheoremPaper), finder.performSearchById("arXiv:1405.2249")); + } + @Test public void searchEntryByIdWith5Digits() throws Exception { assertEquals(Optional.of(