blob: 9e107580fbfaf62562535a5caf2492837d161719 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package gallery
import (
"path/filepath"
"strings"
)
func filterQueryPhotos(
photos []Photo,
query Query,
) []Photo {
if query.Extension == "" {
return photos
}
filtered := make([]Photo, 0, len(photos))
for _, photo := range photos {
ext := strings.TrimPrefix(filepath.Ext(photo.RelativePath), ".")
if strings.EqualFold(ext, query.Extension) {
filtered = append(filtered, photo)
}
}
return filtered
}
|