diff --git a/src/main/java/com/github/_1c_syntax/utils/Absolute.java b/src/main/java/com/github/_1c_syntax/utils/Absolute.java index 42ed1d4..1d14ce2 100644 --- a/src/main/java/com/github/_1c_syntax/utils/Absolute.java +++ b/src/main/java/com/github/_1c_syntax/utils/Absolute.java @@ -36,7 +36,7 @@ public static URI uri(String uri) { } public static URI uri(URI uri) { - var decodedUri = URI.create(uri.getScheme() + ":" + uri.getSchemeSpecificPart()); + var decodedUri = URI.create(uri.getScheme() + ":" + uri.getSchemeSpecificPart().replace(" ", "%20")); if ("file".equals(decodedUri.getScheme()) && decodedUri.getAuthority() == null) { return path(new File(decodedUri)).toUri(); diff --git a/src/test/java/com/github/_1c_syntax/utils/AbsoluteTest.java b/src/test/java/com/github/_1c_syntax/utils/AbsoluteTest.java index ca8ec47..0726525 100644 --- a/src/test/java/com/github/_1c_syntax/utils/AbsoluteTest.java +++ b/src/test/java/com/github/_1c_syntax/utils/AbsoluteTest.java @@ -144,4 +144,15 @@ void testUriFromUntitledFromVSC() { assertThat(uri).hasScheme("untitled"); } + @Test + void testUriFromStringWithSpaces() { + // given + var uriString = "file:///fake%20path/fake.bsl"; + + // when + var uri = Absolute.uri(uriString); + + // then + assertThat(uri.getPath()).endsWith("fake.bsl"); + } } \ No newline at end of file