generated from CleanroomMC/TemplateDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
6 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |