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

ArXiv fetcher support http url #4367

Merged
merged 3 commits into from
Oct 10, 2018
Merged
Changes from 1 commit
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
17 changes: 9 additions & 8 deletions src/main/java/org/jabref/logic/importer/fetcher/ArXiv.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ public List<BibEntry> performSearch(String query) throws FetcherException {

@Override
public Optional<BibEntry> performSearchById(String identifier) throws FetcherException {
String cleanedIdentifier = identifier.trim();
cleanedIdentifier = identifier.replaceAll(" ", "");
String cleanedIdentifier = identifier.replaceAll(" ", "");
cleanedIdentifier = ArXivEntry.createIdString(cleanedIdentifier);

return searchForEntryById(cleanedIdentifier).map((arXivEntry) -> arXivEntry.toBibEntry(importFormatPreferences.getKeywordSeparator()));
}
Expand Down Expand Up @@ -372,17 +372,18 @@ public Optional<URL> getPdfUrl() {
* Returns the arXiv identifier
*/
public Optional<String> getIdString() {
return urlAbstractPage.map(ArXivEntry::createIdString);
}

public static String createIdString(String id) {

return urlAbstractPage.map(abstractUrl -> {
Matcher matcher = URL_PATTERN.matcher(abstractUrl);
Matcher matcher = URL_PATTERN.matcher(id);
if (matcher.find()) {
// remove leading http(s)://arxiv.org/abs/ from abstract url to get arXiv ID
return abstractUrl.substring(matcher.group(1).length());
return id.substring(matcher.group(1).length());
} else {
return abstractUrl;
return id;
}

});
}

public Optional<ArXivIdentifier> getId() {
Expand Down