Skip to content

Commit d03c71f

Browse files
committed
Move isOnlineFile to model
add changelog
1 parent 7cae604 commit d03c71f

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
3636
- We fixed an issue where JabRef would freeze when trying to replace the original entry after a merge with new information from identifiers like DOI/ISBN etc. [3294](https://github.com/JabRef/jabref/issues/3294)
3737
- We fixed an issue where JabRef would not show the translated content at some points, although there existed a translation
3838
- We fixed an issue where editing in the source tab would override content of other entries [#3352](https://github.com/JabRef/jabref/issues/3352#issue-268580818)
39-
### Removed
39+
- We fixed an issue where file links created under windows could not be opened on Linux/OSX [#3311](https://github.com/JabRef/jabref/issues/3311)
40+
41+
### Removed
4042

4143

4244

src/main/java/org/jabref/logic/util/io/FileUtil.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,6 @@ public static String getValidFileName(String fileName) {
9292
return fileName;
9393
}
9494

95-
/**
96-
* Checks if the given String is an online link
97-
* @param toCheck The String to check
98-
* @return True if it starts with http://, https:// or contains www; false otherwise
99-
*/
100-
public static boolean isOnlineLink(String toCheck) {
101-
return toCheck.startsWith("http://") || toCheck.startsWith("https://") || toCheck.contains("www.");
102-
}
103-
10495
/**
10596
* Adds an extension to the given file name. The original extension is not replaced. That means, "demo.bib", ".sav"
10697
* gets "demo.bib.sav" and not "demo.sav"

src/main/java/org/jabref/model/entry/LinkedFile.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import javafx.beans.property.SimpleStringProperty;
1616
import javafx.beans.property.StringProperty;
1717

18-
import org.jabref.logic.util.io.FileUtil;
1918
import org.jabref.model.database.BibDatabaseContext;
2019
import org.jabref.model.metadata.FileDirectoryPreferences;
2120
import org.jabref.model.util.FileHelper;
@@ -36,7 +35,7 @@ public LinkedFile(String description, String link, String fileType) {
3635
this.description.setValue(Objects.requireNonNull(description));
3736

3837
String fileLink = Objects.requireNonNull(link);
39-
if (!FileUtil.isOnlineLink(fileLink)) {
38+
if (!FileHelper.isOnlineLink(fileLink)) {
4039
this.link.setValue(fileLink.replace("\\", "/"));
4140
} else {
4241
this.link.setValue(fileLink);
@@ -70,7 +69,7 @@ public String getLink() {
7069
}
7170

7271
public void setLink(String link) {
73-
if (!FileUtil.isOnlineLink(link)) {
72+
if (!FileHelper.isOnlineLink(link)) {
7473
this.link.setValue(link.replace("\\", "/"));
7574
} else {
7675
this.link.setValue(link);
@@ -137,7 +136,7 @@ public boolean isEmpty() {
137136
}
138137

139138
public boolean isOnlineLink() {
140-
return FileUtil.isOnlineLink(link.get());
139+
return FileHelper.isOnlineLink(link.get());
141140
}
142141

143142
public Optional<Path> findIn(BibDatabaseContext databaseContext, FileDirectoryPreferences fileDirectoryPreferences) {

src/main/java/org/jabref/model/util/FileHelper.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414

1515
public class FileHelper {
1616

17+
/**
18+
* Checks if the given String is an online link
19+
* @param toCheck The String to check
20+
* @return True if it starts with http://, https:// or contains www; false otherwise
21+
*/
22+
public static boolean isOnlineLink(String toCheck) {
23+
return toCheck.startsWith("http://") || toCheck.startsWith("https://") || toCheck.contains("www.");
24+
}
25+
1726
/**
1827
* Returns the extension of a file or Optional.empty() if the file does not have one (no . in name).
1928
*

0 commit comments

Comments
 (0)