Skip to content

Commit

Permalink
fix JabRef#7452: Adds ignore parameter to minetyp and notify the user…
Browse files Browse the repository at this point in the history
… if the file downloaded is HTML
  • Loading branch information
binsu-kth committed Feb 28, 2021
1 parent e50566a commit 622abb9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Set;
import java.util.TreeSet;

import org.apache.commons.lang3.StringUtils;
import org.jabref.gui.Globals;
import org.jabref.logic.bibtex.FileFieldWriter;
import org.jabref.model.entry.LinkedFile;
Expand Down Expand Up @@ -111,6 +112,8 @@ public Optional<ExternalFileType> getExternalFileTypeForName(String filename) {
* guaranteed to be returned.
*/
public Optional<ExternalFileType> getExternalFileTypeByMimeType(String mimeType) {
// Ignores parameters according to link: (https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types)
mimeType=StringUtils.substringBefore(mimeType,";").trim();
for (ExternalFileType type : externalFileTypes) {
if (type.getMimeType().equalsIgnoreCase(mimeType)) {
return Optional.of(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@ public void download() {
linkedFiles.set(oldFileIndex, newLinkedFile);
}
entry.setFiles(linkedFiles);
// Notify in bar when the filetype is HTML.
if (newLinkedFile.getFileType().equals(StandardExternalFileType.URL.getName())) {
dialogService.notify("Downloaded a linked HTML file.");
}
});
downloadProgress.bind(downloadTask.workDonePercentageProperty());
downloadTask.titleProperty().set(Localization.lang("Downloading"));
Expand Down

0 comments on commit 622abb9

Please sign in to comment.