Skip to content

Commit

Permalink
Ignore mime type params (JabRef#7452)
Browse files Browse the repository at this point in the history
Adds ignore parameter to mime type and notify the user if the file downloaded is HTML.
  • Loading branch information
binsu-kth authored and grundb committed Mar 4, 2021
1 parent 2643357 commit c6e95c7
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 c6e95c7

Please sign in to comment.