11package utils ;
22
3+ import java .io .UnsupportedEncodingException ;
34import java .net .URI ;
5+ import java .net .URLDecoder ;
6+ import java .nio .charset .StandardCharsets ;
47import java .nio .file .Path ;
58import java .nio .file .Paths ;
69
@@ -34,6 +37,7 @@ public static boolean isFileInDirectory(String fileUri, String directoryUri) {
3437 * @return base path
3538 */
3639 public static String extractBasePath (String fullPath ) {
40+ fullPath = convertUTFtoCharacters (fullPath );
3741 fullPath = fullPath .replace (FILE_PREFIX , "" );
3842 int suffixIndex = fullPath .indexOf (SRC_SUFFIX );
3943 int nextSlashIndex = fullPath .indexOf ("/" , suffixIndex + SRC_SUFFIX .length ());
@@ -42,6 +46,20 @@ public static String extractBasePath(String fullPath) {
4246 return fullPath .substring (0 , nextSlashIndex ); // up to and including the next slash after /src/
4347 }
4448
49+ /**
50+ * Converts a UTF-8 encoded string to a regular string
51+ * @param source
52+ * @return converted string
53+ */
54+ private static String convertUTFtoCharacters (String source ) {
55+ try {
56+ return URLDecoder .decode (source , StandardCharsets .UTF_8 .name ());
57+ } catch (UnsupportedEncodingException e ) {
58+ // not going to happen - value came from JDK's own StandardCharsets
59+ return null ;
60+ }
61+ }
62+
4563 /**
4664 * Converts a file path to a file:// URI
4765 * @param filePath the file path
0 commit comments