aboutsummaryrefslogtreecommitdiffhomepage
path: root/resources
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-02-20 16:08:18 +0100
committerBjørn Erik Pedersen <[email protected]>2024-02-20 16:47:07 +0100
commit48eec2a4e63cb0b542858f3b133eba19aa23978c (patch)
tree5b14e75413397dbb9e78ab6ac6e6ebf8862ae763 /resources
parenta118cb4138bc903566ade49a7789d91657898a21 (diff)
downloadhugo-48eec2a4e63cb0b542858f3b133eba19aa23978c.tar.gz
hugo-48eec2a4e63cb0b542858f3b133eba19aa23978c.zip
Fall back to original name in Resources.GetMatch/Match
Same as we do in .Get. Fixes #12076
Diffstat (limited to 'resources')
-rw-r--r--resources/resource/resources.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/resources/resource/resources.go b/resources/resource/resources.go
index 9f298b7a6..fb5f9a5ee 100644
--- a/resources/resource/resources.go
+++ b/resources/resource/resources.go
@@ -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
}