diff options
Diffstat (limited to 'resources/resource_factories/create/remote.go')
-rw-r--r-- | resources/resource_factories/create/remote.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/resources/resource_factories/create/remote.go b/resources/resource_factories/create/remote.go index 56bd99cb1..32dfafe5c 100644 --- a/resources/resource_factories/create/remote.go +++ b/resources/resource_factories/create/remote.go @@ -27,6 +27,7 @@ import ( "strings" "github.com/gohugoio/hugo/common/hugio" + "github.com/gohugoio/hugo/common/maps" "github.com/gohugoio/hugo/common/types" "github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/media" @@ -79,7 +80,7 @@ func (c *Client) FromRemote(uri string, optionsm map[string]any) (resource.Resou return nil, errors.Wrapf(err, "failed to parse URL for resource %s", uri) } - resourceID := helpers.HashString(uri, optionsm) + resourceID := calculateResourceID(uri, optionsm) _, httpResponse, err := c.cacheGetResource.GetOrCreate(resourceID, func() (io.ReadCloser, error) { options, err := decodeRemoteOptions(optionsm) @@ -199,6 +200,13 @@ func (c *Client) validateFromRemoteArgs(uri string, options fromRemoteOptions) e return nil } +func calculateResourceID(uri string, optionsm map[string]any) string { + if key, found := maps.LookupEqualFold(optionsm, "key"); found { + return helpers.HashString(key) + } + return helpers.HashString(uri, optionsm) +} + func addDefaultHeaders(req *http.Request, accepts ...string) { for _, accept := range accepts { if !hasHeaderValue(req.Header, "Accept", accept) { |