Skip to content

Commit

Permalink
core: Code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cederberg committed Dec 9, 2023
1 parent 7f05c76 commit e9b53c7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/java/org/rapidcontext/util/ClasspathUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public static URL locate(Class<?> cls, String path) {
if (path.startsWith("classpath:")) {
path = path.substring(10);
}
path = path.replaceAll("//", "/");
if (!path.startsWith("/")) {
path = "/" + path;
path = path.replace("//", File.separator);
if (!path.startsWith(File.separator)) {
path = File.separator + path;
}
return cls.getResource(path);
}
Expand Down Expand Up @@ -105,15 +105,15 @@ public static File locateFile(Class<?> cls) {
str = path.toLowerCase();
if (str.startsWith("jar:")) {
path = path.substring(4);
if (path.indexOf("!/") >= 0) {
if (path.contains("!/")) {
path = path.substring(0, path.indexOf("!/"));
}
} else if (str.startsWith("file:/")) {
path = path.substring(6);
if (!path.startsWith("/")) {
path = "/" + path;
if (!path.startsWith(File.separator)) {
path = File.separator + path;
}
while (path.length() > 1 && path.charAt(1) == '/') {
while (path.length() > 1 && path.charAt(1) == File.separatorChar) {
path = path.substring(1);
}
}
Expand All @@ -139,7 +139,7 @@ public static Manifest manifest(Class<?> cls) {
try {
JarURLConnection con = (JarURLConnection) url.openConnection();
return con.getManifest();
} catch (Throwable ignore) {
} catch (Exception ignore) {
// Ignore errors, return null instead
}
}
Expand Down

0 comments on commit e9b53c7

Please sign in to comment.