Skip to content

Commit

Permalink
Add handling for non standard paths on Windows (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
breedloj authored Dec 6, 2024
1 parent 6246096 commit b11599a
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
package software.aws.toolkits.eclipse.amazonq.views;

import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;

Expand Down Expand Up @@ -112,8 +113,13 @@ public void onAuthStatusChanged(final AuthState authState) {
private String getContent() {
try {
URL jsFile = PluginUtils.getResource("webview/build/assets/js/getStart.js");
var jsParent = Paths.get(jsFile.toURI()).getParent();
var jsDirectoryPath = Path.of(jsParent.toUri()).normalize().toString();
String decodedPath = URLDecoder.decode(jsFile.getPath(), StandardCharsets.UTF_8);

// Remove leading slash for Windows paths
decodedPath = decodedPath.replaceFirst("^/([A-Za-z]:)", "$1");

Path jsParent = Paths.get(decodedPath).getParent();
String jsDirectoryPath = jsParent.normalize().toString();

webviewAssetServer = new WebviewAssetServer();
var result = webviewAssetServer.resolve(jsDirectoryPath);
Expand Down Expand Up @@ -170,7 +176,7 @@ private String getContent() {
</html>
""",
loginJsPath, loginJsPath, loginJsPath, getWaitFunction(), isDarkTheme);
} catch (IOException | URISyntaxException e) {
} catch (IOException e) {
return "Failed to load JS";
}
}
Expand Down

0 comments on commit b11599a

Please sign in to comment.