diff --git a/src/main/java/net/prominic/groovyls/util/URIUtils.java b/src/main/java/net/prominic/groovyls/util/URIUtils.java index 1eec0f08b..acf1a6c7c 100644 --- a/src/main/java/net/prominic/groovyls/util/URIUtils.java +++ b/src/main/java/net/prominic/groovyls/util/URIUtils.java @@ -1,22 +1,17 @@ package net.prominic.groovyls.util; -import java.io.UnsupportedEncodingException; import java.net.URI; -import java.net.URLDecoder; public final class URIUtils { public static URI toUri(String uriString) { - try { - // for some reason vscode like to output garbage like file:///c%3A/Users/.. - var decodedUriString = URLDecoder.decode(uriString, "UTF-8"); + // for some reason vscode like to output garbage like file:///c%3A/Users/.. + // we cant decode here since paths with spaces will cause an error in URI.create() + var decodedUriString = uriString;//URLDecoder.decode(uriString, "UTF-8"); - if (decodedUriString.matches("^file:///[a-z]:/.*$")) { - decodedUriString = "file:///" + decodedUriString.substring(8, 9).toUpperCase() + decodedUriString.substring(9); - } - return URI.create(decodedUriString); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); + if (decodedUriString.matches("^file:///[a-z]:/.*$")) { + decodedUriString = "file:///" + decodedUriString.substring(8, 9).toUpperCase() + decodedUriString.substring(9); } + return URI.create(decodedUriString); } }