mirror of
https://github.com/j3ssie/osmedeus.git
synced 2026-09-11 20:27:47 +02:00
feat: add string utility functions and decision condition tests
- Add cut_to_file() and cut_space() utility functions for file processing and field extraction - Add comprehensive E2E tests for decision condition routing with function/command execution - Add test workflows for decision conditions and inline decision execution - Add short-mode skip guards to all cloud E2E tests to allow quick test runs - Register new functions in constants and goja runtime
This commit is contained in:
@@ -267,6 +267,28 @@ func (vf *vmFunc) cutWithDelim(call goja.FunctionCall) goja.Value {
|
||||
return vf.vm.ToValue(parts[idx])
|
||||
}
|
||||
|
||||
// cutSpace extracts a field from input split by whitespace (1-indexed)
|
||||
// Uses strings.Fields() which handles multiple spaces, tabs, and mixed whitespace
|
||||
// Usage: cut_space(input, field) -> string
|
||||
func (vf *vmFunc) cutSpace(call goja.FunctionCall) goja.Value {
|
||||
input := call.Argument(0).String()
|
||||
field := call.Argument(1).ToInteger()
|
||||
|
||||
if input == "undefined" {
|
||||
return vf.vm.ToValue("")
|
||||
}
|
||||
|
||||
parts := strings.Fields(input)
|
||||
|
||||
// Field is 1-indexed (like cut command)
|
||||
idx := int(field) - 1
|
||||
if idx < 0 || idx >= len(parts) {
|
||||
return vf.vm.ToValue("")
|
||||
}
|
||||
|
||||
return vf.vm.ToValue(parts[idx])
|
||||
}
|
||||
|
||||
// normalizePath replaces special characters with underscore for clean directory/file names
|
||||
// Replaces: / | : \ * ? " < > with _
|
||||
// Usage: normalize_path(input) -> string
|
||||
|
||||
Reference in New Issue
Block a user