Skip to content

Commit

Permalink
Hacking
Browse files Browse the repository at this point in the history
  • Loading branch information
philwebb committed May 6, 2024
1 parent 8a72e55 commit 043720a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 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 @@ -38,7 +38,6 @@
import java.util.Map;
import java.util.Map.Entry;

import org.springframework.boot.loader.net.util.UrlDecoder;
import org.springframework.boot.loader.ref.Cleaner;

/**
Expand Down Expand Up @@ -77,7 +76,7 @@ class NestedUrlConnection extends URLConnection {

private NestedLocation parseNestedLocation(URL url) throws MalformedURLException {
try {
return NestedLocation.parse(UrlDecoder.decode(url.getPath()));
return NestedLocation.fromUrl(url);
}
catch (IllegalArgumentException ex) {
throw new MalformedURLException(ex.getMessage());
Expand Down

0 comments on commit 043720a

Please sign in to comment.