Skip to content

Commit

Permalink
cli: also support "/" on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesKaufmann committed Jan 16, 2025
1 parent 82abe34 commit 12115d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cli/html2markdown/cmd/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ func TestExecute_DirectoryOutput(t *testing.T) {
}

// - - - - - - - - - //
args := []string{"html2markdown", "--input", inputPath, "--output", directoryPath + string(os.PathSeparator)}
pathSeparator := "/" // <-- we don't use os.PathSeparator here just to test that windows also supports slash
args := []string{"html2markdown", "--input", inputPath, "--output", directoryPath + pathSeparator}

stdin := &FakeFile{mode: modeTerminal}
stdout := &FakeFile{mode: modePipe}
Expand Down
5 changes: 3 additions & 2 deletions cli/html2markdown/cmd/io_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ const (

// The user can indicate that they mean a directory by having a slash as the suffix.
func hasFolderSuffix(outputPath string) bool {
// With the trailing slash a directory can be indicated.
return strings.HasSuffix(outputPath, string(os.PathSeparator))
// Note: We generally support the os.PathSeparator (e.g. "\" on windows).
// But also "/" is always supported.
return strings.HasSuffix(outputPath, string(os.PathSeparator)) || strings.HasSuffix(outputPath, "/")
}

func determineOutputType(_inputPath string, countInputs int, outputPath string) (outputType, error) {
Expand Down

0 comments on commit 12115d5

Please sign in to comment.