From: Bjørn Erik Pedersen Date: Sun, 15 Feb 2026 22:24:51 +0000 (+0100) Subject: output: Remove unused method X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=8d19f5a78b88db795cfc5e406eaec19816e8c65e;p=brevno-suite%2Fhugo output: Remove unused method Closes #14522 --- diff --git a/output/outputFormat.go b/output/outputFormat.go index 8f3716e3e..a3c32b477 100644 --- a/output/outputFormat.go +++ b/output/outputFormat.go @@ -309,36 +309,6 @@ func (formats Formats) GetByNames(names ...string) (Formats, error) { return types, nil } -// FromFilename gets a Format given a filename. -func (formats Formats) FromFilename(filename string) (f Format, found bool) { - // mytemplate.amp.html - // mytemplate.html - // mytemplate - var ext, outFormat string - - parts := strings.Split(filename, ".") - if len(parts) > 2 { - outFormat = parts[1] - ext = parts[2] - } else if len(parts) > 1 { - ext = parts[1] - } - - if outFormat != "" { - return formats.GetByName(outFormat) - } - - if ext != "" { - f, found = formats.GetBySuffix(ext) - if !found && len(parts) == 2 { - // For extensionless output formats (e.g. Netlify's _redirects) - // we must fall back to using the extension as format lookup. - f, found = formats.GetByName(ext) - } - } - return -} - // BaseFilename returns the base filename of f including an extension (ie. // "index.xml"). func (f Format) BaseFilename() string { diff --git a/output/outputFormat_test.go b/output/outputFormat_test.go index 5950c590c..7b87ff753 100644 --- a/output/outputFormat_test.go +++ b/output/outputFormat_test.go @@ -98,45 +98,6 @@ func TestGetFormatByExt(t *testing.T) { c.Assert(found, qt.Equals, false) } -func TestGetFormatByFilename(t *testing.T) { - c := qt.New(t) - noExtNoDelimMediaType := media.Builtin.TextType - noExtNoDelimMediaType.Delimiter = "" - - noExtMediaType := media.Builtin.TextType - - var ( - noExtDelimFormat = Format{ - Name: "NEM", - MediaType: noExtNoDelimMediaType, - BaseName: "_redirects", - } - noExt = Format{ - Name: "NEX", - MediaType: noExtMediaType, - BaseName: "next", - } - ) - - formats := Formats{AMPFormat, HTMLFormat, noExtDelimFormat, noExt, CalendarFormat} - f, found := formats.FromFilename("my.amp.html") - c.Assert(found, qt.Equals, true) - c.Assert(f, qt.Equals, AMPFormat) - _, found = formats.FromFilename("my.ics") - c.Assert(found, qt.Equals, true) - f, found = formats.FromFilename("my.html") - c.Assert(found, qt.Equals, true) - c.Assert(f, qt.Equals, HTMLFormat) - f, found = formats.FromFilename("my.nem") - c.Assert(found, qt.Equals, true) - c.Assert(f, qt.Equals, noExtDelimFormat) - f, found = formats.FromFilename("my.nex") - c.Assert(found, qt.Equals, true) - c.Assert(f, qt.Equals, noExt) - _, found = formats.FromFilename("my.css") - c.Assert(found, qt.Equals, false) -} - func TestSort(t *testing.T) { c := qt.New(t) c.Assert(DefaultFormats[0].Name, qt.Equals, "html")