Skip to content

Commit

Permalink
Fix exception when editing URL file (#8009)
Browse files Browse the repository at this point in the history
* Fix exception when editing URL file

Fixes #8008

* fix checkstyle and add changelog
  • Loading branch information
Siedlerchr authored Aug 21, 2021
1 parent 07712ce commit 8720fd2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Fixed

- We fixed an issue where an exception ocurred when a linked online file was edited in the entry editor [#8008](https://github.com/JabRef/jabref/issues/8008)
- We fixed an issue when checking for a new version when JabRef is used behind a corporate proxy. [#7884](https://github.com/JabRef/jabref/issues/7884)
- We fixed some icons that were drawn in the wrong color when JabRef used a custom theme. [#7853](https://github.com/JabRef/jabref/issues/7853)
- We fixed an issue where the `Aux file` on `Edit group` doesn't support relative sub-directories path to import. [#7719](https://github.com/JabRef/jabref/issues/7719).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jabref.gui.linkedfile;

import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -125,7 +127,16 @@ public ObjectProperty<ExternalFileType> selectedExternalFileTypeProperty() {
}

public LinkedFile getNewLinkedFile() {
return new LinkedFile(description.getValue(), Path.of(link.getValue()), monadicSelectedExternalFileType.getValue().map(ExternalFileType::toString).orElse(""));
String fileType = monadicSelectedExternalFileType.getValue().map(ExternalFileType::toString).orElse("");

if (LinkedFile.isOnlineLink(link.getValue())) {
try {
return new LinkedFile(description.getValue(), new URL(link.getValue()), fileType);
} catch (MalformedURLException e) {
return new LinkedFile(description.getValue(), link.getValue(), fileType);
}
}
return new LinkedFile(description.getValue(), Path.of(link.getValue()), fileType);
}

private String relativize(Path filePath) {
Expand Down

0 comments on commit 8720fd2

Please sign in to comment.