Add explicit empty code checks in Ruby presenter

Co-authored-by: Tyriar <2193314+Tyriar@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-16 21:58:34 +00:00
co-authored by Tyriar
parent a0278fa841
commit 64baba2b0e
@@ -40,6 +40,11 @@ export function extractRubyCommand(commandLine: string, shell: string, os: Opera
if (doubleQuoteMatch?.groups?.code) {
let rubyCode = doubleQuoteMatch.groups.code.trim();
// Return undefined if the trimmed code is empty
if (!rubyCode) {
return undefined;
}
// Unescape quotes based on shell type
if (isPowerShell(shell, os)) {
// PowerShell uses backtick-quote (`") to escape quotes inside double-quoted strings
@@ -57,7 +62,9 @@ export function extractRubyCommand(commandLine: string, shell: string, os: Opera
// Single quotes in PowerShell are also literal
const singleQuoteMatch = commandLine.match(/^ruby\s+-e\s+'(?<code>.+)'$/s);
if (singleQuoteMatch?.groups?.code) {
return singleQuoteMatch.groups.code.trim();
const rubyCode = singleQuoteMatch.groups.code.trim();
// Return undefined if the trimmed code is empty
return rubyCode || undefined;
}
return undefined;