Skip to content

Commit

Permalink
🐛 Fix funky characters in image names
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed Apr 3, 2024
1 parent 97f3faf commit 8e8d6aa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ public ImageRef buildImageRef(Tools5eIndex index, JsonMediaHref mediaHref, Strin
int pos = fullPath.lastIndexOf('/');
String fileName = fullPath.substring(pos + 1);

int query = fileName.lastIndexOf('?');
if (query >= 0) {
fileName = fileName.substring(0, query);
}

if (type == Tools5eIndexType.deity || type == Tools5eIndexType.note || type == Tools5eIndexType.variantrule) {
fileName = primarySource() + "-" + fileName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static String sourceIfNotDefault(String source, Tools5eIndexType type) {
if (type != null && source.equalsIgnoreCase(type.defaultSourceString())) {
return "";
}
return "-" + source.toLowerCase();
return "-" + Tui.slugify(source);
}
}

Expand All @@ -90,7 +90,7 @@ public static String getDeityResourceName(String name, String source, String pan
switch (pantheon.toLowerCase()) {
case "exandria" -> {
if (!source.equalsIgnoreCase("egw")) {
suffix = "-" + source.toLowerCase();
suffix = "-" + Tui.slugify(source);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/dev/ebullient/convert/Tools5eDataConvertTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ void testLiveData_5eHomebrew(QuarkusMainLauncher launcher) {
"-o", target.toString(),
TestUtils.PATH_5E_TOOLS_DATA.toString()));

// if (TestUtils.PATH_5E_TOOLS_IMAGES.toFile().exists()) {
// args.add(TestUtils.TEST_RESOURCES.resolve("images-from-local.json").toString());
// } else {
args.add(TestUtils.TEST_RESOURCES.resolve("images-remote.json").toString());
// }
if (TestUtils.PATH_5E_TOOLS_IMAGES.toFile().exists()) {
args.add(TestUtils.TEST_RESOURCES.resolve("images-from-local.json").toString());
} else {
args.add(TestUtils.TEST_RESOURCES.resolve("images-remote.json").toString());
}

LaunchResult result = launcher.launch(args.toArray(new String[0]));
assertThat(result.exitCode())
Expand Down
10 changes: 8 additions & 2 deletions src/test/resources/sources-homebrew.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"sources/5e-homebrew/creature/MCDM Productions; Flee, Mortals! preview.json",
"sources/5e-homebrew/creature/MCDM Productions; Flee, Mortals!.json",
"sources/5e-homebrew/creature/Nerzugal Role-Playing; Nerzugal's Extended Bestiary.json",
"sources/5e-homebrew/deity/Frog God Games; The Lost Lands.json"
"sources/5e-homebrew/deity/Frog God Games; The Lost Lands.json",
"sources/5e-homebrew/collection/Loot Tavern; Heliana's Guide To Monster Hunting.json"
]
},
"from": [
Expand All @@ -53,7 +54,12 @@
"race|.*|dmg"
],
"template": {
"background": "examples/templates/tools5e/images-background2md.txt",
"item": "examples/templates/tools5e/images-item2md.txt",
"monster": "src/test/resources/other/monster-all.txt",
"item": "examples/templates/tools5e/images-item2md.txt"
"object": "examples/templates/tools5e/images-object2md.txt",
"race": "examples/templates/tools5e/images-race2md.txt",
"spell": "examples/templates/tools5e/images-spell2md.txt",
"vehicle": "examples/templates/tools5e/images-vehicle2md.txt"
}
}

0 comments on commit 8e8d6aa

Please sign in to comment.