Skip to content

Commit 8e8d6aa

Browse files
committed
🐛 Fix funky characters in image names
1 parent 97f3faf commit 8e8d6aa

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

src/main/java/dev/ebullient/convert/tools/dnd5e/Tools5eSources.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ public ImageRef buildImageRef(Tools5eIndex index, JsonMediaHref mediaHref, Strin
251251
int pos = fullPath.lastIndexOf('/');
252252
String fileName = fullPath.substring(pos + 1);
253253

254+
int query = fileName.lastIndexOf('?');
255+
if (query >= 0) {
256+
fileName = fileName.substring(0, query);
257+
}
258+
254259
if (type == Tools5eIndexType.deity || type == Tools5eIndexType.note || type == Tools5eIndexType.variantrule) {
255260
fileName = primarySource() + "-" + fileName;
256261
}

src/main/java/dev/ebullient/convert/tools/dnd5e/qute/Tools5eQuteBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private static String sourceIfNotDefault(String source, Tools5eIndexType type) {
6666
if (type != null && source.equalsIgnoreCase(type.defaultSourceString())) {
6767
return "";
6868
}
69-
return "-" + source.toLowerCase();
69+
return "-" + Tui.slugify(source);
7070
}
7171
}
7272

@@ -90,7 +90,7 @@ public static String getDeityResourceName(String name, String source, String pan
9090
switch (pantheon.toLowerCase()) {
9191
case "exandria" -> {
9292
if (!source.equalsIgnoreCase("egw")) {
93-
suffix = "-" + source.toLowerCase();
93+
suffix = "-" + Tui.slugify(source);
9494
}
9595
}
9696
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ void testLiveData_5eHomebrew(QuarkusMainLauncher launcher) {
148148
"-o", target.toString(),
149149
TestUtils.PATH_5E_TOOLS_DATA.toString()));
150150

151-
// if (TestUtils.PATH_5E_TOOLS_IMAGES.toFile().exists()) {
152-
// args.add(TestUtils.TEST_RESOURCES.resolve("images-from-local.json").toString());
153-
// } else {
154-
args.add(TestUtils.TEST_RESOURCES.resolve("images-remote.json").toString());
155-
// }
151+
if (TestUtils.PATH_5E_TOOLS_IMAGES.toFile().exists()) {
152+
args.add(TestUtils.TEST_RESOURCES.resolve("images-from-local.json").toString());
153+
} else {
154+
args.add(TestUtils.TEST_RESOURCES.resolve("images-remote.json").toString());
155+
}
156156

157157
LaunchResult result = launcher.launch(args.toArray(new String[0]));
158158
assertThat(result.exitCode())

src/test/resources/sources-homebrew.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"sources/5e-homebrew/creature/MCDM Productions; Flee, Mortals! preview.json",
3333
"sources/5e-homebrew/creature/MCDM Productions; Flee, Mortals!.json",
3434
"sources/5e-homebrew/creature/Nerzugal Role-Playing; Nerzugal's Extended Bestiary.json",
35-
"sources/5e-homebrew/deity/Frog God Games; The Lost Lands.json"
35+
"sources/5e-homebrew/deity/Frog God Games; The Lost Lands.json",
36+
"sources/5e-homebrew/collection/Loot Tavern; Heliana's Guide To Monster Hunting.json"
3637
]
3738
},
3839
"from": [
@@ -53,7 +54,12 @@
5354
"race|.*|dmg"
5455
],
5556
"template": {
57+
"background": "examples/templates/tools5e/images-background2md.txt",
58+
"item": "examples/templates/tools5e/images-item2md.txt",
5659
"monster": "src/test/resources/other/monster-all.txt",
57-
"item": "examples/templates/tools5e/images-item2md.txt"
60+
"object": "examples/templates/tools5e/images-object2md.txt",
61+
"race": "examples/templates/tools5e/images-race2md.txt",
62+
"spell": "examples/templates/tools5e/images-spell2md.txt",
63+
"vehicle": "examples/templates/tools5e/images-vehicle2md.txt"
5864
}
5965
}

0 commit comments

Comments
 (0)