diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2024-02-25 10:24:46 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2024-02-25 14:57:29 +0100 |
commit | d310595a2ba672fa30dc9a9a2679542cfc919a35 (patch) | |
tree | 14ae73ab6bce20d236759d73e6181f006e4de8f4 /resources/resource/resources.go | |
parent | 049dd1d7e0e106d861c60e5417c907bc3a686dcb (diff) |
resource: Revert the normalization of Resource.Name
Which means that .Name now returns the same as it did in 0.122.0.
Closes #12142
Diffstat (limited to 'resources/resource/resources.go')
-rw-r--r-- | resources/resource/resources.go | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/resources/resource/resources.go b/resources/resource/resources.go index fb5f9a5ee..aa01d4ce2 100644 --- a/resources/resource/resources.go +++ b/resources/resource/resources.go @@ -18,7 +18,6 @@ import ( "fmt" "strings" - "github.com/gohugoio/hugo/common/paths" "github.com/gohugoio/hugo/hugofs/glob" "github.com/spf13/cast" ) @@ -73,10 +72,10 @@ func (r Resources) Get(name any) Resource { } } - // Finally, check the original name. + // Finally, check the normalized name. for _, resource := range r { - if nop, ok := resource.(NameOriginalProvider); ok { - if strings.EqualFold(namestr, nop.NameOriginal()) { + if nop, ok := resource.(NameNormalizedProvider); ok { + if strings.EqualFold(namestr, nop.NameNormalized()) { return resource } } @@ -93,23 +92,21 @@ func (r Resources) GetMatch(pattern any) Resource { panic(err) } - patternstr = paths.NormalizePathStringBasic(patternstr) - g, err := glob.GetGlob(patternstr) if err != nil { panic(err) } for _, resource := range r { - if g.Match(paths.NormalizePathStringBasic(resource.Name())) { + if g.Match(resource.Name()) { return resource } } // Finally, check the original name. for _, resource := range r { - if nop, ok := resource.(NameOriginalProvider); ok { - if g.Match(paths.NormalizePathStringBasic(nop.NameOriginal())) { + if nop, ok := resource.(NameNormalizedProvider); ok { + if g.Match(nop.NameNormalized()) { return resource } } @@ -140,15 +137,15 @@ func (r Resources) Match(pattern any) Resources { var matches Resources for _, resource := range r { - if g.Match(strings.ToLower(resource.Name())) { + if g.Match(resource.Name()) { matches = append(matches, resource) } } if len(matches) == 0 { - // Fall back to the original name. + // Fall back to the normalized name. for _, resource := range r { - if nop, ok := resource.(NameOriginalProvider); ok { - if g.Match(strings.ToLower(nop.NameOriginal())) { + if nop, ok := resource.(NameNormalizedProvider); ok { + if g.Match(nop.NameNormalized()) { matches = append(matches, resource) } } |