Skip to content

Commit

Permalink
Hacking
Browse files Browse the repository at this point in the history
  • Loading branch information
philwebb committed May 4, 2024
1 parent 8a72e55 commit 5400a5c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package org.springframework.boot.loader.net.protocol.nested;

import java.io.File;
import java.net.URI;
import java.net.URL;
import java.nio.file.Path;
Expand Down Expand Up @@ -94,28 +93,15 @@ static NestedLocation parse(String path) {
throw new IllegalArgumentException("'path' must not be empty");
}
int index = path.lastIndexOf("/!");
return cache.computeIfAbsent(path, (l) -> create(index, l));
return cache.computeIfAbsent(path, (location) -> create(location, index));
}

private static NestedLocation create(int index, String location) {
private static NestedLocation create(String location, int index) {
String locationPath = (index != -1) ? location.substring(0, index) : location;
if (isWindows() && !isUncPath(location)) {
while (locationPath.startsWith("/")) {
locationPath = locationPath.substring(1, locationPath.length());
}
}
String nestedEntryName = (index != -1) ? location.substring(index + 2) : null;
return new NestedLocation((!locationPath.isEmpty()) ? Path.of(locationPath) : null, nestedEntryName);
}

private static boolean isWindows() {
return File.separatorChar == '\\';
}

private static boolean isUncPath(String input) {
return !input.contains(":");
}

static void clearCache() {
cache.clear();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,6 @@ static class FileAccess {
private final Object lock = new Object();

FileAccess(Path path) {
if (!Files.isRegularFile(path)) {
throw new IllegalArgumentException(path + " must be a regular file");
}
this.path = path;
}

Expand Down

0 comments on commit 5400a5c

Please sign in to comment.