Add a -i flag to force showing 'index.html' in the output listing; by default do not show them.
This commit is contained in:
@@ -158,15 +158,16 @@ var ExtensionTypes = map[string]string{
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
TopDir string
|
||||
Filter string
|
||||
OutputFile string
|
||||
DirAppend bool
|
||||
Recursive bool
|
||||
IncludeHidden bool
|
||||
ExcludeRegex *regexp.Regexp
|
||||
Verbose bool
|
||||
DryRun bool
|
||||
TopDir string
|
||||
Filter string
|
||||
OutputFile string
|
||||
DirAppend bool
|
||||
Recursive bool
|
||||
IncludeHidden bool
|
||||
ExcludeRegex *regexp.Regexp
|
||||
Verbose bool
|
||||
DryRun bool
|
||||
ShowIndexFiles bool
|
||||
}
|
||||
|
||||
type FileEntry struct {
|
||||
@@ -275,7 +276,7 @@ func ReadDirEntries(dirPath string, opts *Options) ([]FileEntry, error) {
|
||||
for _, file := range files {
|
||||
fileName := file.Name()
|
||||
|
||||
if strings.EqualFold(fileName, opts.OutputFile) {
|
||||
if !opts.ShowIndexFiles && strings.EqualFold(fileName, opts.OutputFile) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -101,11 +101,13 @@ func TestHTMLTemplate(t *testing.T) {
|
||||
Entries []FileEntry
|
||||
DirAppend bool
|
||||
OutputFile string
|
||||
IsRoot bool
|
||||
}{
|
||||
DirName: "test-dir",
|
||||
Entries: []FileEntry{},
|
||||
DirAppend: false,
|
||||
OutputFile: "index.html",
|
||||
IsRoot: false,
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
@@ -161,11 +163,13 @@ func TestHTMLTemplateWithEntries(t *testing.T) {
|
||||
Entries []FileEntry
|
||||
DirAppend bool
|
||||
OutputFile string
|
||||
IsRoot bool
|
||||
}{
|
||||
DirName: "test-dir",
|
||||
Entries: entries,
|
||||
DirAppend: false,
|
||||
OutputFile: "index.html",
|
||||
IsRoot: false,
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
|
||||
@@ -245,9 +245,9 @@ func TestProcessDirWithDirAppend(t *testing.T) {
|
||||
|
||||
htmlContent := string(content)
|
||||
|
||||
// Check that directory links include index.html (URL escaped)
|
||||
if !strings.Contains(htmlContent, "subdir%2Findex.html") {
|
||||
t.Errorf("Directory links should include index.html when DirAppend is true. Expected subdir%%2Findex.html in content")
|
||||
// Check that directory links include index.html
|
||||
if !strings.Contains(htmlContent, "subdir/index.html") {
|
||||
t.Errorf("Directory links should include index.html when DirAppend is true. Expected subdir/index.html in content")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user