mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-28 12:07:35 +01:00
Fix String replacement for player links inside exported JSON
Issue was the JSON escape adding \/ so the replacer did not find ../player as it was ..\/player instead Affects issues: - Fixed #1593
This commit is contained in:
parent
b37edf78fc
commit
e2043715d2
@ -32,6 +32,7 @@ import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.file.PlanFiles;
|
||||
import com.djrapitops.plan.storage.file.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -143,8 +144,8 @@ public class NetworkPageExporter extends FileExporter {
|
||||
export(toDirectory.resolve("data").resolve(jsonResourceName),
|
||||
// Replace ../player in urls to fix player page links
|
||||
StringUtils.replaceEach(found.get().getAsString(),
|
||||
new String[]{"../player", "./player"},
|
||||
new String[]{relativePlayerLink, relativePlayerLink}
|
||||
new String[]{StringEscapeUtils.escapeJson("../player"), StringEscapeUtils.escapeJson("./player")},
|
||||
new String[]{StringEscapeUtils.escapeJson(relativePlayerLink), StringEscapeUtils.escapeJson(relativePlayerLink)}
|
||||
)
|
||||
);
|
||||
exportPaths.put("./v1/" + resource, toRelativePathFromRoot("data/" + jsonResourceName));
|
||||
|
@ -33,6 +33,7 @@ import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.file.PlanFiles;
|
||||
import com.djrapitops.plan.storage.file.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -156,7 +157,11 @@ public class ServerPageExporter extends FileExporter {
|
||||
|
||||
export(toDirectory.resolve("data").resolve(jsonResourceName),
|
||||
// Replace ../player in urls to fix player page links
|
||||
StringUtils.replace(found.get().getAsString(), "../player", toRelativePathFromRoot("player"))
|
||||
StringUtils.replace(
|
||||
found.get().getAsString(),
|
||||
StringEscapeUtils.escapeJson("../player"),
|
||||
StringEscapeUtils.escapeJson(toRelativePathFromRoot("player"))
|
||||
)
|
||||
);
|
||||
exportPaths.put("../v1/" + resource, toRelativePathFromRoot("data/" + jsonResourceName));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user