Skip to content

Commit c004b01

Browse files
authored
fix: adapt input directory handling to preserve whitespaces (#413)
1 parent 87f8e7c commit c004b01

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

pkg/app/app.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,19 @@ func defaultFuncApiUrl(_ configuration.Configuration, logger *zerolog.Logger) co
115115

116116
func defaultInputDirectory() configuration.DefaultValueFunction {
117117
callback := func(_ configuration.Configuration, existingValue interface{}) (interface{}, error) {
118+
// Check if we have a valid string value
118119
existingString, isString := existingValue.(string)
119-
if isString {
120-
existingString = strings.TrimSpace(existingString)
120+
if isString && len(existingString) > 0 {
121+
// Return the string value as-is (preserving any whitespace)
122+
return existingString, nil
121123
}
122124

123-
if len(existingString) == 0 {
124-
path, err := os.Getwd()
125-
if err != nil {
126-
return "", err
127-
}
128-
return path, nil
129-
} else {
130-
return existingString, nil
125+
// Fall back to current working directory for non-string types or empty strings
126+
path, err := os.Getwd()
127+
if err != nil {
128+
return ".", err
131129
}
130+
return path, nil
132131
}
133132
return callback
134133
}

pkg/app/app_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,8 @@ func TestDefaultInputDirectory(t *testing.T) {
498498
name: "path with leading/trailing whitespace",
499499
existingValue: " /path/with/whitespace ",
500500
expectedError: false,
501-
expectedResult: "/path/with/whitespace",
502-
description: "should trim whitespace and return clean path",
501+
expectedResult: " /path/with/whitespace ",
502+
description: "should preserve whitespace and return path exactly as provided",
503503
},
504504
{
505505
name: "non-string type - integer",

0 commit comments

Comments
 (0)