Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add handling for non standard paths on Windows #280

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading