Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
acfde3f
Fixed issue : Add entry using URL #15411
kulkarnisudeep01 Mar 30, 2026
2155a0f
Update CHANGELOG for #15411
kulkarnisudeep01 Mar 30, 2026
fbe7fc8
Update CHANGELOG for #15411
kulkarnisudeep01 Mar 30, 2026
3b8cc73
Fix #15411 : Add tests for GenericUrlBasedFetcher
kulkarnisudeep01 Mar 30, 2026
06baac6
Fix #15411: Address review comments - use withField, trim URL, fix nu…
kulkarnisudeep01 Mar 30, 2026
57174ac
Merge branch 'main' into main
Sudeep-A-Kulkarni Mar 30, 2026
8edc747
Merge branch 'main' into main
Sudeep-A-Kulkarni Mar 30, 2026
2cad645
Merge branch 'main' into main
Sudeep-A-Kulkarni Mar 30, 2026
7116372
Fixed issue : Add entry using URL #15411
kulkarnisudeep01 Mar 30, 2026
501fe67
Update CHANGELOG for #15411
kulkarnisudeep01 Mar 30, 2026
2648a6d
Update CHANGELOG for #15411
kulkarnisudeep01 Mar 30, 2026
d402030
Fix #15411 : Add tests for GenericUrlBasedFetcher
kulkarnisudeep01 Mar 30, 2026
f4b5d1b
Fix #15411: Address review comments - use withField, trim URL, fix nu…
kulkarnisudeep01 Mar 30, 2026
868348e
Fix #15411: Add missing localization keys for Enter URL feature
kulkarnisudeep01 Mar 30, 2026
6444a36
Localize URL fetcher name
kulkarnisudeep01 Mar 30, 2026
5595f37
Localize URL fetcher name
kulkarnisudeep01 Mar 30, 2026
258a140
Fix: restore submodules to upstream state
kulkarnisudeep01 Mar 30, 2026
d41f837
Fix: resolve checkstyle formatting and redundant imports
kulkarnisudeep01 Mar 30, 2026
4368823
Fix markdown linting errors in CHANGELOG
kulkarnisudeep01 Mar 30, 2026
7405062
resolving errors 1
kulkarnisudeep01 Mar 30, 2026
059fff1
Fix #15411: Fix getName and localization keys
kulkarnisudeep01 Mar 31, 2026
0b4c405
Fix #15411: Rename to fetchEntryFromUrl, add URL validation, fix loca…
kulkarnisudeep01 Mar 31, 2026
0138ca8
Fix #15411: Fix trailing whitespace in test file
kulkarnisudeep01 Mar 31, 2026
368e4b7
CHANGELOG update
kulkarnisudeep01 Mar 31, 2026
7b92325
Trigger CI rerun
kulkarnisudeep01 Mar 31, 2026
580d1cf
Removing the triple entry of feature
kulkarnisudeep01 Mar 31, 2026
462ef8b
Removing the duplicates
kulkarnisudeep01 Mar 31, 2026
9cec0cd
Merge branch 'main' into feature/url-based-fetcher
Sudeep-A-Kulkarni Apr 1, 2026
6fc6a26
Merge remote-tracking branch 'upstream/main' into fork/Sudeep-A-Kulka…
calixtus Apr 2, 2026
c922846
Fix submodules
calixtus Apr 2, 2026
3e98ae0
Merge branch 'main' into feature/url-based-fetcher
Sudeep-A-Kulkarni Apr 2, 2026
e358e88
Merge branch 'main' into feature/url-based-fetcher
Sudeep-A-Kulkarni Apr 2, 2026
c8a3bb5
Address review comments: fix URL validation, remove UrlBasedFetcher, …
kulkarnisudeep01 Apr 3, 2026
2e22acc
Merge branch 'main' into feature/url-based-fetcher
Sudeep-A-Kulkarni Apr 3, 2026
98a60ce
Merge branch 'main' into feature/url-based-fetcher
Sudeep-A-Kulkarni Apr 3, 2026
82094db
Refactor tests : merged TESTURL into 1
kulkarnisudeep01 Apr 3, 2026
158586b
Updating changes
kulkarnisudeep01 Apr 3, 2026
0a1245f
Fixing the issues caused by merge
kulkarnisudeep01 Apr 3, 2026
3cae28d
Resolving markdown issue in CHANGELOG.md
kulkarnisudeep01 Apr 3, 2026
d59b52f
removing duplicates from CHANGELOG.md
kulkarnisudeep01 Apr 3, 2026
d9f024e
Merge remote-tracking branch 'upstream/main' into fork/Sudeep-A-Kulka…
calixtus Apr 3, 2026
e1ecdb0
Fix submodules again
calixtus Apr 3, 2026
6a91b76
Merge branch 'main' into feature/url-based-fetcher
Sudeep-A-Kulkarni Apr 3, 2026
22d764c
Fix submodules
calixtus Apr 3, 2026
3f23503
Update CHANGELOG by removing spaces
Sudeep-A-Kulkarni Apr 5, 2026
4043778
Refactor NewEntryViewModel constructor and validators
Sudeep-A-Kulkarni Apr 5, 2026
68a9caf
Update NewEntryViewModel.java
Sudeep-A-Kulkarni Apr 5, 2026
e2e0526
Update NewEntryViewModel.java
Sudeep-A-Kulkarni Apr 5, 2026
b352767
Update NewEntryViewModel.java
Sudeep-A-Kulkarni Apr 5, 2026
04b0e36
Update NewEntryViewModel.java
Sudeep-A-Kulkarni Apr 5, 2026
e011b4d
Update NewEntryViewModel.java
Sudeep-A-Kulkarni Apr 5, 2026
de5ff86
Update NewEntryViewModel.java
Sudeep-A-Kulkarni Apr 5, 2026
8be07a0
Update NewEntryViewModel.java
Sudeep-A-Kulkarni Apr 5, 2026
c52e877
Update GenericUrlBasedFetcher.java
Sudeep-A-Kulkarni Apr 5, 2026
6991fe8
Update UrlBasedFetcher.java
Sudeep-A-Kulkarni Apr 5, 2026
16f3673
Delete jablib/src/main/java/org/jabref/logic/importer/UrlBasedFetcher…
Sudeep-A-Kulkarni Apr 6, 2026
1c96e84
Update GenericUrlBasedFetcher.java
Sudeep-A-Kulkarni Apr 6, 2026
a19e09b
Update GenericUrlBasedFetcher.java
Sudeep-A-Kulkarni Apr 6, 2026
aa45263
Update GenericUrlBasedFetcher.java
Sudeep-A-Kulkarni Apr 6, 2026
0cae7f4
Update GenericUrlBasedFetcher.java
Sudeep-A-Kulkarni Apr 7, 2026
ce5d37e
Update GenericUrlBasedFetcherTest.java
Sudeep-A-Kulkarni Apr 7, 2026
666577c
Update GenericUrlBasedFetcher.java
Sudeep-A-Kulkarni Apr 7, 2026
a1e8208
Update GenericUrlBasedFetcherTest.java
Sudeep-A-Kulkarni Apr 7, 2026
a5f8efa
Update GenericUrlBasedFetcher.java
Sudeep-A-Kulkarni Apr 7, 2026
917fff6
Update GenericUrlBasedFetcher.java
Sudeep-A-Kulkarni Apr 7, 2026
0dc5b3e
Update GenericUrlBasedFetcherTest.java
Sudeep-A-Kulkarni Apr 7, 2026
4aa8026
Update GenericUrlBasedFetcher.java
Sudeep-A-Kulkarni Apr 7, 2026
05ee0fe
Update GenericUrlBasedFetcher.java
Sudeep-A-Kulkarni Apr 7, 2026
0dd0056
Update GenericUrlBasedFetcher.java
Sudeep-A-Kulkarni Apr 7, 2026
9626864
Update GenericUrlBasedFetcher.java
Sudeep-A-Kulkarni Apr 7, 2026
cc86e6d
Update GenericUrlBasedFetcherTest.java
Sudeep-A-Kulkarni Apr 7, 2026
39eee8e
Update GenericUrlBasedFetcher.java
Sudeep-A-Kulkarni Apr 7, 2026
ba81759
Update GenericUrlBasedFetcher.java
Sudeep-A-Kulkarni Apr 7, 2026
60d4b41
Update GenericUrlBasedFetcherTest.java
Sudeep-A-Kulkarni Apr 7, 2026
e6d5eb9
Update GenericUrlBasedFetcher.java
Sudeep-A-Kulkarni Apr 7, 2026
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Comment thread
InAnYan marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
### Added

- We added support for downloading full-text PDFs from Wiley journals via the Wiley TDM API. [#13404](https://github.com/JabRef/jabref/issues/13404)
- We added "Enter URL" tab in New Entry dialog to create a `@Misc` entry from any URL. [#15411](https://github.com/JabRef/jabref/issues/15411)
- We added `--key-patterns` option to CLI parameters to allows users to set a citation key's pattern for a specific entry type. [#14707](https://github.com/JabRef/jabref/issues/14707)
- We added a CLI option `--field-formatters` to the `convert` and `generate-bib-from-aux` commands to apply field formatters during export. [#11520](https://github.com/JabRef/jabref/issues/11520)
- We added a preference to skip the import dialog for entries received from browser extensions, allowing direct import into the current library. The import dialog is shown by default; users can enable direct import in Preferences.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ public enum NewEntryDialogTab {
ENTER_IDENTIFIER,
INTERPRET_CITATIONS,
SPECIFY_BIBTEX,
ENTER_URL,
}
39 changes: 39 additions & 0 deletions jabgui/src/main/java/org/jabref/gui/newentry/NewEntryView.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public class NewEntryView extends BaseDialog<BibEntry> {

@FXML private TextArea bibtexText;

@FXML private Tab tabEnterUrl;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can move this line below @FXML private Tab tabSpecifyBibtex;

@FXML private TextField urlText;

private BibEntry result;

public NewEntryView(NewEntryDialogTab initialApproach, GuiPreferences preferences, LibraryTab libraryTab, DialogService dialogService) {
Expand Down Expand Up @@ -206,12 +209,17 @@ private void finalizeTabs() {
tabs.getSelectionModel().select(tabSpecifyBibtex);
switchSpecifyBibtex();
break;
case NewEntryDialogTab.ENTER_URL:
tabs.getSelectionModel().select(tabEnterUrl);
switchEnterUrl();
break;
}

tabAddEntry.setOnSelectionChanged(_ -> switchAddEntry());
tabLookupIdentifier.setOnSelectionChanged(_ -> switchLookupIdentifier());
tabInterpretCitations.setOnSelectionChanged(_ -> switchInterpretCitations());
tabSpecifyBibtex.setOnSelectionChanged(_ -> switchSpecifyBibtex());
tabEnterUrl.setOnSelectionChanged(_ -> switchEnterUrl());
}

@FXML
Expand All @@ -234,6 +242,7 @@ public void initialize() {
initializeLookupIdentifier();
initializeInterpretCitations();
initializeSpecifyBibTeX();
initializeEnterUrl();
Copy link
Copy Markdown
Collaborator

@pluto-han pluto-han Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change the name? "EnterUrl" is the action of end users. Here, it should be something JabRef does.

Also for switchEnterUrl, tabEnterUrl, etc...

}

private void initializeAddEntry() {
Expand Down Expand Up @@ -472,6 +481,31 @@ private void switchSpecifyBibtex() {
}
}

@FXML
private void switchEnterUrl() {
if (!tabEnterUrl.isSelected()) {
return;
}

currentApproach = NewEntryDialogTab.ENTER_URL;
newEntryPreferences.setLatestApproach(NewEntryDialogTab.ENTER_URL);

if (urlText != null) {
Platform.runLater(() -> urlText.requestFocus());
}
Comment on lines +493 to +495
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clipboard content should also be in the text field.

see dialog-with-text-input.md


if (generateButton != null) {
generateButton.disableProperty().bind(
viewModel.urlTextValidatorProperty().not()
);
generateButton.setText(Localization.lang("Search"));
}
}

private void initializeEnterUrl() {
urlText.textProperty().bindBidirectional(viewModel.urlTextProperty());
}

private void onEntryTypeSelected(EntryType type) {
newEntryPreferences.setLatestImmediateType(type);
result = new BibEntry(type);
Expand Down Expand Up @@ -507,6 +541,11 @@ private void execute() {
viewModel.executeSpecifyBibtex();
switchSpecifyBibtex();
break;
case NewEntryDialogTab.ENTER_URL:
generateButton.setText(Localization.lang("Searching..."));
viewModel.executeEnterUrl();
switchEnterUrl();
break;
}
}

Expand Down
Comment thread
InAnYan marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -33,13 +34,15 @@
import org.jabref.logic.importer.IdBasedFetcher;
import org.jabref.logic.importer.ParseException;
import org.jabref.logic.importer.WebFetchers;
import org.jabref.logic.importer.fetcher.GenericUrlBasedFetcher;
import org.jabref.logic.importer.fileformat.BibtexParser;
import org.jabref.logic.importer.plaincitation.PlainCitationParser;
import org.jabref.logic.importer.plaincitation.PlainCitationParserChoice;
import org.jabref.logic.importer.plaincitation.PlainCitationParserFactory;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.layout.LayoutFormatter;
import org.jabref.logic.layout.format.DOIStrip;
import org.jabref.logic.util.URLUtil;
import org.jabref.logic.util.strings.StringUtil;
import org.jabref.model.TransferInformation;
import org.jabref.model.TransferMode;
Expand Down Expand Up @@ -91,6 +94,9 @@ public class NewEntryViewModel {
private final StringProperty bibtexText;
private final Validator bibtexTextValidator;
private Task<Optional<List<BibEntry>>> bibtexWorker;
private final StringProperty urlText;
private final Validator urlTextValidator;
private Task<Optional<List<BibEntry>>> urlWorker;
private final Map<String, BibEntry> doiCache;
private BibEntry duplicateEntry;

Expand Down Expand Up @@ -150,6 +156,22 @@ public NewEntryViewModel(GuiPreferences preferences,
StringUtil::isNotBlank,
ValidationMessage.error(Localization.lang("You must specify a Bib(La)TeX source.")));
bibtexWorker = null;

urlText = new SimpleStringProperty("");
urlTextValidator = new FunctionBasedValidator<>(urlText, input -> {
if (StringUtil.isBlank(input)) {
return false;
}

String normalized = input.trim();
String lower = normalized.toLowerCase(Locale.ROOT);

if (!lower.startsWith("http://") && !lower.startsWith("https://")) {
normalized = "https://" + normalized;
}

return URLUtil.isValidHttpUrl(normalized);
}, ValidationMessage.error(Localization.lang("Please enter a valid HTTP or HTTPS URL.")));
Comment on lines +160 to +174
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Url scheme not stored 🐞 Bug ≡ Correctness

The URL validator accepts schemeless inputs by prepending "https://" only for validation, but the
worker/fetcher persists the original text, so entries can be created with invalid URL values (e.g.,
"example.com"). This breaks the promise of “valid URL” and can lead to non-clickable/unusable URL
fields downstream.
Agent Prompt
### Issue description
The URL validator prepends `https://` for validation, but the actual stored URL comes from the original `urlText` value, which may be schemeless. This allows a value to be considered “valid” in the UI while persisting an invalid URL into the created `@Misc` entry.

### Issue Context
- Validation currently normalizes into a local variable only.
- `WorkerLookupUrl` passes the original `urlText` to `GenericUrlBasedFetcher`.
- `GenericUrlBasedFetcher` trims and stores the URL as-is.

### Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/newentry/NewEntryViewModel.java[160-174]
- jabgui/src/main/java/org/jabref/gui/newentry/NewEntryViewModel.java[502-520]
- jablib/src/main/java/org/jabref/logic/importer/fetcher/GenericUrlBasedFetcher.java[16-27]

### Suggested fix
Apply the same normalization used during validation to the value that is persisted, e.g.:
- Normalize in `WorkerLookupUrl.call()` (preferred: single point before fetch/import), and pass `normalized` to the fetcher.
  - `normalized = text.trim();`
  - If missing scheme, prefix `https://`.
- Or move normalization into `GenericUrlBasedFetcher.fetchEntryFromUrl` so all callers get consistent behavior.
- Optionally update `urlText` with the normalized value so the UI and stored data match exactly.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Why add http:// in a validator? So you add http:// for the url and expect validator to return error "Please enter a valid HTTP or HTTPS URL."?|

  2. What is lower and normalized? Bad naming

  3. What if users use "http://1234" or even "1234", validity check still passes...

  4. Line 169-171 is duplicate with Line 22-24 in GenericUrlBasedFetcher.java‎

}

public void populateDOICache() {
Expand Down Expand Up @@ -238,6 +260,14 @@ public ReadOnlyBooleanProperty bibtexTextValidatorProperty() {
return bibtexTextValidator.getValidationStatus().validProperty();
}

public StringProperty urlTextProperty() {
return urlText;
}

public ReadOnlyBooleanProperty urlTextValidatorProperty() {
return urlTextValidator.getValidationStatus().validProperty();
}

private BibEntry withCoversDownloaded(BibEntry entry) {
if (preferences.getPreviewPreferences().shouldDownloadCovers()) {
bookCoverFetcher.downloadCoversForEntry(entry);
Expand Down Expand Up @@ -469,6 +499,27 @@ protected Optional<List<BibEntry>> call() throws ParseException {
}
}

private class WorkerLookupUrl extends Task<Optional<List<BibEntry>>> {
@Override
protected Optional<List<BibEntry>> call() throws FetcherException {
final String text = urlText.getValue();
final boolean textValid = urlTextValidator.getValidationStatus().isValid();

if (text == null || !textValid) {
return Optional.empty();
}

GenericUrlBasedFetcher fetcher = new GenericUrlBasedFetcher();

List<BibEntry> entries = fetcher.fetchEntryFromUrl(text);

if (entries.isEmpty()) {
return Optional.empty();
}
return Optional.of(entries);
}
}

public void executeSpecifyBibtex() {
executing.setValue(true);

Expand Down Expand Up @@ -534,6 +585,42 @@ public void executeSpecifyBibtex() {
taskExecutor.execute(bibtexWorker);
}

public void executeEnterUrl() {
executing.setValue(true);

cancel();
urlWorker = new WorkerLookupUrl();

urlWorker.setOnFailed(_ -> {
final Throwable exception = urlWorker.getException();
final String exceptionMessage = Optional.ofNullable(exception.getMessage()).orElse(exception.toString());
LOGGER.error("An exception occurred when looking up URL.", exception);

dialogService.showInformationDialogAndWait(Localization.lang("Failed to look up URL"), Localization.lang("The following error occurred:\n%0", exceptionMessage));

executing.set(false);
});

urlWorker.setOnSucceeded(_ -> {
final Optional<List<BibEntry>> result = urlWorker.getValue();

if (result.isEmpty()) {
dialogService.showWarningDialogAndWait(Localization.lang("Invalid result"), Localization.lang("No entry could be generated from the provided URL.\n" + "This entry may need to be added manually."));
executing.set(false);
return;
}

final ImportHandler handler = new ImportHandler(libraryTab.getBibDatabaseContext(), preferences, fileUpdateMonitor, libraryTab.getUndoManager(), stateManager, dialogService, taskExecutor);

handler.importEntriesWithDuplicateCheck(null, result.get());

executedSuccessfully.set(true);
executing.set(false);
});

taskExecutor.execute(urlWorker);
}

public void cancel() {
if (idLookupWorker != null) {
idLookupWorker.cancel();
Expand All @@ -544,5 +631,9 @@ public void cancel() {
if (bibtexWorker != null) {
bibtexWorker.cancel();
}

if (urlWorker != null) {
urlWorker.cancel();
}
}
}
28 changes: 28 additions & 0 deletions jabgui/src/main/resources/org/jabref/gui/newentry/NewEntry.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,34 @@
wrapText="true"/>
</VBox>
</Tab>

<Tab fx:id="tabEnterUrl"
text="%Enter URL"
closable="false">
<VBox spacing="10.0">
<padding>
<Insets top="10.0"/>
</padding>
<Label text="%Enter a URL to generate an entry from.">
<font>
<Font name="System Italic"
size="13.0"/>
</font>
<padding>
<Insets bottom="5.0"/>
</padding>
</Label>
<HBox alignment="CENTER_LEFT"
spacing="10.0">
<Label text="%URL"/>
<TextField
fx:id="urlText"
prefHeight="30.0"
HBox.hgrow="ALWAYS"/>
</HBox>
</VBox>
</Tab>

</TabPane>
</content>
<ButtonType
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.jabref.logic.importer.fetcher;

import java.util.List;

import org.jabref.logic.importer.FetcherException;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.types.StandardEntryType;

public class GenericUrlBasedFetcher {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quote from issue description: "Add one implementation GenericUrlBasedFetcher just generating a @misc entry with URL."

You mark this PR reviewable again without doing anything from #15458 (review)???


public String getName() {
return "Generic URL Fetcher";
}
Comment on lines +12 to +14
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement getName() in WebFetcher interface.

What's the use of a method if its only called by test?


public List<BibEntry> fetchEntryFromUrl(String url) throws FetcherException {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FetcherException is never used?

if (url == null || url.trim().isEmpty()) {
return List.of();
}

String trimmedUrl = url.trim();
if (!trimmedUrl.startsWith("http://") && !trimmedUrl.startsWith("https://")) {
trimmedUrl = "https://" + trimmedUrl;
}

BibEntry entry = new BibEntry(StandardEntryType.Misc)
.withField(StandardField.URL, trimmedUrl);
return List.of(entry);
Comment on lines +21 to +28
Copy link
Copy Markdown
Collaborator

@pluto-han pluto-han Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many flaws...

  1. It creats ONE entry and puts it into a list? So this method always returns a list containing ONE element?!

  2. This class is a "fetcher", but only creates a bibentry with the url? At least it should "fetch" something? Otherwise, is there any useful information for users? Please think about the requirement as a "user": what do you want for this feature?

Image
  1. I dont get the point of trimmedUrl, I think its a very very bad name...Also, you add url.trim().isEmpty() above, why don't you trim it at the very beginning, so you don't have to trim twice...

  2. You should at least check if the url is valid in viewmodel...

Image

}
}
6 changes: 6 additions & 0 deletions jablib/src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3009,6 +3009,12 @@ Enter\ Bib(La)TeX\ sources\ to\ generate\ entries\ from.=Enter Bib(La)TeX source
Enter\ Identifier=Enter Identifier
Enter\ identifier...=Enter identifier...
Enter\ identifier=Enter identifier
Enter\ URL=Enter URL
Enter\ a\ URL\ to\ generate\ an\ entry\ from.=Enter a URL to generate an entry from.
Failed\ to\ look\ up\ URL=Failed to look up URL
No\ entry\ could\ be\ generated\ from\ the\ provided\ URL.\nThis\ entry\ may\ need\ to\ be\ added\ manually.=No entry could be generated from the provided URL.\nThis entry may need to be added manually.
URL=URL
Please\ enter\ a\ valid\ HTTP\ or\ HTTPS\ URL.=Please enter a valid HTTP or HTTPS URL.
Enter\ plain\ citations\ to\ parse,\ separated\ by\ blank\ lines.=Enter plain citations to parse, separated by blank lines.
Enter\ the\ reference\ identifier\ to\ search\ for.=Enter the reference identifier to search for.
Entry\ already\ exists\ in\ a\ library=Entry already exists in a library
Expand Down
Comment thread
InAnYan marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.jabref.logic.importer.fetcher;

import java.util.List;
import java.util.Optional;

import org.jabref.logic.importer.FetcherException;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.types.StandardEntryType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

class GenericUrlBasedFetcherTest {
private static final String TEST_URL = "https://gi-radar.de/397-coding-unterstuetzung-im-lauf-der-zeit/";
private GenericUrlBasedFetcher fetcher;

@BeforeEach
void setUp() {
fetcher = new GenericUrlBasedFetcher();
}

@Test
void getNameReturnsCorrectName() {
assertEquals("Generic URL Fetcher", fetcher.getName());
}

@Test
void fetchEntryFromUrlWithValidUrlCreatesCorrectEntry() throws FetcherException {
List<BibEntry> results = fetcher.fetchEntryFromUrl(TEST_URL);
assertEquals(1, results.size());
BibEntry entry = results.get(0);
assertEquals(Optional.of(TEST_URL), entry.getField(StandardField.URL));
assertEquals(StandardEntryType.Misc, entry.getType());
}

@Test
void fetchEntryFromUrlWithBlankUrlReturnsEmptyList() throws FetcherException {
List<BibEntry> results = fetcher.fetchEntryFromUrl(" ");
assertTrue(results.isEmpty());
}

@Test
void fetchEntryFromUrlTrimsUrl() throws FetcherException {
List<BibEntry> results = fetcher.fetchEntryFromUrl(" " + TEST_URL + " ");
assertEquals(1, results.size());
assertEquals(Optional.of(TEST_URL), results.get(0).getField(StandardField.URL));
}
}
Loading