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

devonfw / IDEasy / 7278937169

20 Dec 2023 05:43PM UTC coverage: 47.802% (-0.07%) from 47.873%
7278937169

Pull #151

github

web-flow
Merge 09b6148ea into 1d60d9c17
Pull Request #151: #20: Implement ToolCommandlet for GCViewer

1031 of 2383 branches covered (0.0%)

Branch coverage included in aggregate %.

2721 of 5466 relevant lines covered (49.78%)

2.05 hits per line

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

79.31
cli/src/main/java/com/devonfw/tools/ide/util/FilenameUtil.java
1
package com.devonfw.tools.ide.util;
2

3
import java.util.Locale;
4

5
/**
6
 * Utility class for filenames and extensions.
7
 */
8
public final class FilenameUtil {
9

10
  private FilenameUtil() {
11

12
    // construction forbidden
13
  }
14

15
  /**
16
   * @param path the file or path name to get the extension from.
17
   * @return the file extension excluding the dot from the given {@code path} or {@code null} if no extension is
18
   *         present.
19
   */
20
  public static String getExtension(String path) {
21

22
    if (path == null) {
2!
23
      return null;
×
24
    }
25
    path = path.toLowerCase(Locale.ROOT);
4✔
26
    int lastSlash = path.lastIndexOf('/');
4✔
27
    if (lastSlash < 0) {
2✔
28
      lastSlash = 0;
2✔
29
    }
30
    int lastDot = path.lastIndexOf('.');
4✔
31

32
    // workaround for sourceforge urls
33
    if (path.contains("sourceforge") && path.endsWith("download")) {
4!
34
      return path.substring(lastDot + 1, lastSlash);
×
35
    }
36

37
    if (lastDot < lastSlash) {
3✔
38
      return null;
2✔
39
    }
40
    // include previous ".tar" for ".tar.gz" or ".tar.bz2"
41
    int rawNameLength = lastDot - lastSlash;
4✔
42
    if ((rawNameLength > 4) && path.substring(lastDot - 4, lastDot).equals(".tar")) {
12✔
43
      lastDot = lastDot - 4;
4✔
44
    }
45
    return path.substring(lastDot + 1);
6✔
46
  }
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