@@ -98,3 +98,152 @@ func TestCopyPageShouldFail(t *testing.T) {
9898 b .Assert (err , qt .IsNotNil )
9999
100100}
101+
102+ func TestMatchPatternCaseSensitivity (t * testing.T ) {
103+ t .Parallel ()
104+
105+ files := `
106+ -- config.toml --
107+ baseURL = "http://example.com/blog"
108+ -- assets/DIR1/sub/x.txt --
109+ content in x.txt
110+ -- assets/dir2/SUB/y.txt --
111+ content in y.txt
112+ -- layouts/index.html --
113+ {{ with resources.GetMatch "DIR1/sub/x.txt" }}
114+ GetMatch "DIR1/sub/x.txt" | .Content => {{ .Content }}
115+ GetMatch "DIR1/sub/x.txt" | .Name => {{ .Name }}
116+ {{ end }}
117+
118+ {{ with resources.GetMatch "dir2/SUB/y.txt" }}
119+ GetMatch "dir2/SUB/y.txt" | .Content => {{ .Content }}
120+ GetMatch "dir2/SUB/y.txt" | .Name => {{ .Name }}
121+ {{ end }}
122+
123+ {{ with resources.GetMatch "dir1/sub/x.txt" }}
124+ GetMatch "dir1/sub/x.txt" | .Content => {{ .Content }}
125+ GetMatch "dir1/sub/x.txt" | .Name => {{ .Name }}
126+ {{ end }}
127+
128+ {{ with resources.GetMatch "dir2/sub/y.txt" }}
129+ GetMatch "dir2/sub/y.txt" | .Content => {{ .Content }}
130+ GetMatch "dir2/sub/y.txt" | .Name => {{ .Name }}
131+ {{ end }}
132+
133+ {{ with resources.GetMatch "DIR1/SUB/X.TXT" }}
134+ GetMatch "DIR1/SUB/X.TXT" | .Content => {{ .Content }}
135+ GetMatch "DIR1/SUB/X.TXT" | .Name => {{ .Name }}
136+ {{ end }}
137+
138+ {{ with resources.GetMatch "DIR2/SUB/Y.TXT" }}
139+ GetMatch "DIR2/SUB/Y.TXT" | .Content => {{ .Content }}
140+ GetMatch "DIR2/SUB/Y.TXT" | .Name => {{ .Name }}
141+ {{ end }}
142+
143+ {{ with resources.GetMatch "DIR1/*/x.txt" }}
144+ GetMatch "DIR1/*/x.txt" | .Content => {{ .Content }}
145+ GetMatch "DIR1/*/x.txt" | .Name => {{ .Name }}
146+ {{ end }}
147+
148+ {{ with resources.GetMatch "dir2/*/y.txt" }}
149+ GetMatch "dir2/*/y.txt" | .Content => {{ .Content }}
150+ GetMatch "dir2/*/y.txt" | .Name => {{ .Name }}
151+ {{ end }}
152+
153+ {{ with resources.GetMatch "dir1/*/x.txt" }}
154+ GetMatch "dir1/*/x.txt" | .Content => {{ .Content }}
155+ GetMatch "dir1/*/x.txt" | .Name => {{ .Name }}
156+ {{ end }}
157+
158+ {{ with resources.GetMatch "DIR2/*/Y.TXT" }}
159+ GetMatch "DIR2/*/Y.TXT" | .Content => {{ .Content }}
160+ GetMatch "DIR2/*/Y.TXT" | .Name => {{ .Name }}
161+ {{ end }}
162+
163+ {{ with resources.GetMatch "DIR1/**/x.txt" }}
164+ GetMatch "DIR1/**/x.txt" | .Content => {{ .Content }}
165+ GetMatch "DIR1/**/x.txt" | .Name => {{ .Name }}
166+ {{ end }}
167+
168+ {{ with resources.GetMatch "dir2/**/y.txt" }}
169+ GetMatch "dir2/**/y.txt" | .Content => {{ .Content }}
170+ GetMatch "dir2/**/y.txt" | .Name => {{ .Name }}
171+ {{ end }}
172+
173+ {{ with resources.GetMatch "dir1/**/x.txt" }}
174+ GetMatch "dir1/**/x.txt" | .Content => {{ .Content }}
175+ GetMatch "dir1/**/x.txt" | .Name => {{ .Name }}
176+ {{ end }}
177+
178+ {{ with resources.GetMatch "DIR2/**/Y.TXT" }}
179+ GetMatch "DIR2/**/Y.TXT" | .Content => {{ .Content }}
180+ GetMatch "DIR2/**/Y.TXT" | .Name => {{ .Name }}
181+ {{ end }}
182+
183+ {{ with resources.Match "**/*.txt" }}
184+ Match "**/*.txt" | len => {{ len . }}
185+ {{ end }}
186+
187+ {{ with resources.Match "*/*/*.txt" }}
188+ Match "*/*/*.txt" | len => {{ len . }}
189+ {{ end }}
190+
191+ `
192+
193+ b := hugolib .NewIntegrationTestBuilder (
194+ hugolib.IntegrationTestConfig {
195+ T : t ,
196+ TxtarString : files ,
197+ NeedsOsFS : true ,
198+ }).Build ()
199+
200+ want := `
201+ GetMatch "DIR1/sub/x.txt" | .Content => content in x.txt
202+ GetMatch "DIR1/sub/x.txt" | .Name => DIR1/sub/x.txt
203+
204+ GetMatch "dir2/SUB/y.txt" | .Content => content in y.txt
205+ GetMatch "dir2/SUB/y.txt" | .Name => dir2/SUB/y.txt
206+
207+ GetMatch "dir1/sub/x.txt" | .Content => content in x.txt
208+ GetMatch "dir1/sub/x.txt" | .Name => DIR1/sub/x.txt
209+
210+ GetMatch "dir2/sub/y.txt" | .Content => content in y.txt
211+ GetMatch "dir2/sub/y.txt" | .Name => dir2/SUB/y.txt
212+
213+ GetMatch "DIR1/SUB/X.TXT" | .Content => content in x.txt
214+ GetMatch "DIR1/SUB/X.TXT" | .Name => DIR1/sub/x.txt
215+
216+ GetMatch "DIR2/SUB/Y.TXT" | .Content => content in y.txt
217+ GetMatch "DIR2/SUB/Y.TXT" | .Name => dir2/SUB/y.txt
218+
219+ GetMatch "DIR1/*/x.txt" | .Content => content in x.txt
220+ GetMatch "DIR1/*/x.txt" | .Name => DIR1/sub/x.txt
221+
222+ GetMatch "dir2/*/y.txt" | .Content => content in y.txt
223+ GetMatch "dir2/*/y.txt" | .Name => dir2/SUB/y.txt
224+
225+ GetMatch "dir1/*/x.txt" | .Content => content in x.txt
226+ GetMatch "dir1/*/x.txt" | .Name => DIR1/sub/x.txt
227+
228+ GetMatch "DIR2/*/Y.TXT" | .Content => content in y.txt
229+ GetMatch "DIR2/*/Y.TXT" | .Name => dir2/SUB/y.txt
230+
231+ GetMatch "DIR1/**/x.txt" | .Content => content in x.txt
232+ GetMatch "DIR1/**/x.txt" | .Name => DIR1/sub/x.txt
233+
234+ GetMatch "dir2/**/y.txt" | .Content => content in y.txt
235+ GetMatch "dir2/**/y.txt" | .Name => dir2/SUB/y.txt
236+
237+ GetMatch "dir1/**/x.txt" | .Content => content in x.txt
238+ GetMatch "dir1/**/x.txt" | .Name => DIR1/sub/x.txt
239+
240+ GetMatch "DIR2/**/Y.TXT" | .Content => content in y.txt
241+ GetMatch "DIR2/**/Y.TXT" | .Name => dir2/SUB/y.txt
242+
243+ Match "*/*/*.txt" | len => 2
244+ Match "**/*.txt" | len => 2
245+ `
246+
247+ b .AssertFileContent ("public/index.html" , want )
248+
249+ }
0 commit comments