]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
output: Remove unused method
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 15 Feb 2026 22:24:51 +0000 (23:24 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 16 Feb 2026 10:00:33 +0000 (11:00 +0100)
Closes #14522

output/outputFormat.go
output/outputFormat_test.go

index 8f3716e3ee9d9a0ed9d36b22ea407689ac781008..a3c32b47755f6178d76c84476bab3a5d010ea1bc 100644 (file)
@@ -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 {
index 5950c590c70816c393c321008e6aee59a0fa184c..7b87ff7534afae68f24b832f6d81eae5932e6217 100644 (file)
@@ -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")