Fix Windows path handling for nested jars

Update `Path` creation for nested locations to allow both UNC and classic
file references to be used. This commit attempts to align our URL
handling with that of standard file URLs. The `NestedLocation` class
no longer attempts to remove leading all `\` characters and instead
only removes the first `\` when the second char is `:`. This duplicates
the logic found in Java's own internal `WindowsUriSupport` class which
is used when calling `Path.of(url)` with a `file:` URL.

Fixes gh-40549
This commit is contained in:
Phillip Webb
2024-05-08 15:34:32 -07:00
parent ed42ed7c43
commit 7708ec7592
4 changed files with 28 additions and 25 deletions

View File

@@ -85,7 +85,7 @@ class NestedLocationTests {
@Test
void fromUrlWhenNoPathThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() -> NestedLocation.fromUrl(new URL("nested:")))
.withMessageContaining("'path' must not be empty");
.withMessageContaining("'location' must not be empty");
}
@Test