From 89746825b1557d0837295ddeb5b4eecc8c375869 Mon Sep 17 00:00:00 2001 From: Nikita Gryzlov Date: Mon, 6 Apr 2020 14:54:05 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BF=D1=83=D1=82=D0=B5=D0=B9=20=D1=81=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B1=D0=B5=D0=BB=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/github/_1c_syntax/utils/Absolute.java | 2 +- .../com/github/_1c_syntax/utils/AbsoluteTest.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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