Skip to content

Commit

Permalink
Merge pull request #1591 from jplag/fix/slash-windows
Browse files Browse the repository at this point in the history
Fix slash issues
  • Loading branch information
tsaglam authored Feb 21, 2024
2 parents dc1d2df + f72d745 commit 18d0c16
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/src/main/java/de/jplag/reporting/FilePathUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

public final class FilePathUtil {
private static final String ZIP_PATH_SEPARATOR = "/"; // Paths in zip files are always separated by a slash
private static final String WINDOWS_PATH_SEPARATOR = "\\";

private FilePathUtil() {
// private constructor to prevent instantiation
Expand Down Expand Up @@ -35,12 +36,12 @@ public static String getRelativeSubmissionPath(File file, Submission submission,
*/
public static String joinZipPathSegments(String left, String right) {
String rightStripped = right;
while (rightStripped.startsWith(ZIP_PATH_SEPARATOR)) {
while (rightStripped.startsWith(ZIP_PATH_SEPARATOR) || rightStripped.startsWith(WINDOWS_PATH_SEPARATOR)) {
rightStripped = rightStripped.substring(1);
}

String leftStripped = left;
while (leftStripped.endsWith(ZIP_PATH_SEPARATOR)) {
while (leftStripped.endsWith(ZIP_PATH_SEPARATOR) || leftStripped.startsWith(WINDOWS_PATH_SEPARATOR)) {
leftStripped = leftStripped.substring(0, leftStripped.length() - 1);
}

Expand Down

0 comments on commit 18d0c16

Please sign in to comment.