Skip to content

Commit

Permalink
fix lsp uri parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
brachy84 committed Jul 20, 2024
1 parent 764d560 commit 6bd82e7
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/main/java/net/prominic/groovyls/util/URIUtils.java
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 6bd82e7

Please sign in to comment.