Skip to content

Commit 383888f

Browse files
committed
🐛 fix image urls
1 parent 8c2dba0 commit 383888f

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/main/java/dev/ebullient/convert/config/TtrpgConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ public String getRootPath() {
178178
return internalImageRoot;
179179
}
180180

181+
public String getRootPathUrl() {
182+
return internalImageRoot.startsWith("http") || internalImageRoot.startsWith("file")
183+
? internalImageRoot
184+
: "file://" + internalImageRoot;
185+
}
186+
181187
public boolean copyInternalToVault() {
182188
return copyInternal;
183189
}

src/main/java/dev/ebullient/convert/qute/ImageRef.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,18 +216,16 @@ public ImageRef build() {
216216

217217
sourceUrl = java.net.URLDecoder.decode(sourceUrl, StandardCharsets.UTF_8);
218218

219-
boolean copyToVault = false;
219+
boolean copyToVault = imageRoot.copyExternalToVault();
220220

221221
if (sourceUrl.startsWith("http") || sourceUrl.startsWith("file")) {
222222
sourceUrl = sourceUrl.replaceAll("^(https?):/+", "$1://");
223-
copyToVault = imageRoot.copyExternalToVault();
224223
} else if (sourceUrl.startsWith("stream/")) {
225224
copyToVault = true;
226-
} else if (!sourceUrl.startsWith("file:/")) {
227-
copyToVault = imageRoot.copyInternalToVault();
225+
} else {
228226
sourceUrl = copyToVault
229227
? imageRoot.getRootPath() + sourceUrl
230-
: "file://" + imageRoot.getRootPath() + sourceUrl;
228+
: imageRoot.getRootPathUrl() + sourceUrl;
231229
}
232230

233231
boolean localTargetSet = relativeTarget != null && vaultRoot != null && rootFilePath != null;

src/test/java/dev/ebullient/convert/TestUtils.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ public static void checkMarkdownLink(String baseDir, Path p, String line, List<S
9999
if (path.startsWith("http") && path.contains(" ")) {
100100
e.add(String.format("HTTP path with space in %s: %s ", p, m.group(0)));
101101
return;
102+
} else if (path.contains("file://https://")) {
103+
e.add(String.format("file://https:// in %s: %s ", p, m.group(0)));
104+
return;
102105
} else if (path.startsWith("http")
103106
|| path.startsWith("file://")
104107
|| path.contains("vaultPath")

0 commit comments

Comments
 (0)