gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.4k stars 7.49k forks source link

resources.Match is always returning lower case paths #10112

Open ekutner opened 2 years ago

ekutner commented 2 years ago

What version of Hugo are you using (hugo version)?

$ hugo version
hugo v0.101.0-466fa43c16709b4483689930a4f9ac8add5c9f66+extended windows/amd64 BuildDate=2022-06-16T07:09:16Z VendorInfo=gohugoio

Calling _resources.Match to fetch files from the assets folder with a path that contains upper case letters is returning results where the path is converted to lower case.

For example, this code:

    {{- $images := resources.Match "gallery/Travel/Iceland/*.jpg" -}}
    {{ range $image := $images}}
        {{ $image.RelPermalink}}<br>
    {{ end }}

Produces results that look like: /gallery/travel/iceland/DJI_0026-Edit.jpg

But they should be: /gallery/Travel/Iceland/DJI_0026-Edit.jpg

Notes:

  1. Only the path was converted to lowercase, the file name remained correct as it should.
  2. The underlying file system has the same upper case structure as passed to the function, so the results should match that.
  3. I've set disablePathToLower: true in my config but that doesn't seem to make a difference.
  4. I'm running this on Windows, which is case insensitive so testing locally with "hugo server" works fine but when it is deployed to a Linux server it doesn't work because the paths are wrong.

Workaround: Searching for "*gallery/Travel/Iceland/*.jpg" produces correct results.

jmooring commented 2 years ago

This seems like a duplicate of https://github.com/gohugoio/hugo/issues/7686.

ekutner commented 2 years ago

@jmooring Although it's related I don't think it's the same thing. In the other issue the match fails, in this case it succeeds but the results have lower case paths. My guess is that the root cause might be the same. If the search string is converted to lower case before searching then on Linux it wouldn't find any matches, on windows it does but it probably just concatenates the path back to the found files instead of using the response from the file system, so it's still lowercase.

jmooring commented 2 years ago

MRE

git clone --single-branch -b hugo-github-issue-10112 https://github.com/jmooring/hugo-testing hugo-github-issue-10112
cd hugo-github-issue-10112
hugo server
bep commented 2 years ago

What does MRE mean?

jmooring commented 2 years ago

Minimal reproducible example. Sorry, I will stop using that abbreviation.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open. If this is a feature request, and you feel that it is still relevant and valuable, please tell us why. This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.