mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-14 20:33:59 +02:00
Fall back to original name in Resources.GetMatch/Match
Same as we do in .Get. Fixes #12076
This commit is contained in:
@@ -106,6 +106,15 @@ func (r Resources) GetMatch(pattern any) Resource {
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, check the original name.
|
||||
for _, resource := range r {
|
||||
if nop, ok := resource.(NameOriginalProvider); ok {
|
||||
if g.Match(paths.NormalizePathStringBasic(nop.NameOriginal())) {
|
||||
return resource
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -135,6 +144,16 @@ func (r Resources) Match(pattern any) Resources {
|
||||
matches = append(matches, resource)
|
||||
}
|
||||
}
|
||||
if len(matches) == 0 {
|
||||
// Fall back to the original name.
|
||||
for _, resource := range r {
|
||||
if nop, ok := resource.(NameOriginalProvider); ok {
|
||||
if g.Match(strings.ToLower(nop.NameOriginal())) {
|
||||
matches = append(matches, resource)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return matches
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user