• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kit-data-manager / ro-crate-java / #431

19 May 2025 02:23PM UTC coverage: 90.418% (+0.2%) from 90.169%
#431

Pull #258

github

web-flow
Merge 896018de9 into 810d1995c
Pull Request #258: Support .ELN-style crates in all zip readers and writers

283 of 315 new or added lines in 25 files covered. (89.84%)

1 existing line in 1 file now uncovered.

2010 of 2223 relevant lines covered (90.42%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.82
/src/main/java/edu/kit/datamanager/ro_crate/util/FileSystemUtil.java
1
package edu.kit.datamanager.ro_crate.util;
2

3
import java.util.Collection;
4
import java.util.regex.Matcher;
5

6
public class FileSystemUtil {
7
    private FileSystemUtil() {
8
        // Utility class, no instantiation
9
    }
10

11
    /**
12
     * Removes a specific set of given file extensions from a file name, if present.
13
     * The extensions are case-insensitive. Given "ELN", "eln" or "Eln" will also match.
14
     * The dot (.) before the extension is also assumed and removed implicitly:
15
     * <p>
16
     * Example:
17
     * filterExtensionsFromFileName("test.eln", Set.of("ELN")) -> "test"
18
     *
19
     * @param filename the file name to filter
20
     * @param extensionsToRemove the extensions to remove
21
     * @return the filtered file name
22
     */
23
    public static String filterExtensionsFromFileName(String filename, Collection<String> extensionsToRemove) {
24
        String dot = Matcher.quoteReplacement(".");
1✔
25
        String end = Matcher.quoteReplacement("$");
1✔
26
        for (String extension : extensionsToRemove) {
1✔
27
            // (?i) removes case sensitivity
28
            filename = filename.replaceFirst("(?i)" + dot + extension + end, "");
1✔
29
        }
1✔
30
        return filename;
1✔
31
    }
32

33
    /**
34
     * Ensures that a given path ends with a trailing slash.
35
     *
36
     * @param path the path to check
37
     * @return the path with a trailing slash if it didn't have one, or the original path
38
     */
39
    public static String ensureTrailingSlash(String path) {
40
        if (path == null || path.isEmpty()) {
1✔
NEW
41
            return path;
×
42
        }
43
        if (!path.endsWith("/")) {
1✔
44
            return path + "/";
1✔
45
        }
NEW
46
        return path;
×
47
    }
48
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc