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