Skip to content

Commit 5ceeaba

Browse files
authored
fix(amazonq transform): failure if whitespace in JAVA_HOME aws#4725
Problem: Users can provide a JAVA_HOME with trailing or leading whitespaces, this causes issues when resolving the JAVA_HOME. Solution: Using `.trim()` to do preliminary cleanup of the string.
1 parent 975f8d3 commit 5ceeaba

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/core/src/amazonqGumby/chat/controller/controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ export class GumbyController {
346346
* Examples:
347347
* ```
348348
* extractPath("./some/path/here") => "C:/some/root/some/path/here"
349+
* extractPath(" ./some/path/here\n") => "C:/some/root/some/path/here"
349350
* extractPath("C:/some/nonexistent/path/here") => undefined
350351
* extractPath("C:/some/filepath/.txt") => undefined
351352
* ```
@@ -354,6 +355,6 @@ export class GumbyController {
354355
* @returns the absolute path if path points to existing folder, otherwise undefined
355356
*/
356357
function extractPath(text: string): string | undefined {
357-
const resolvedPath = path.resolve(text)
358+
const resolvedPath = path.resolve(text.trim())
358359
return fs.existsSync(resolvedPath) && fs.lstatSync(resolvedPath).isDirectory() ? resolvedPath : undefined
359360
}

0 commit comments

Comments
 (0)