Skip to content

Commit b259f88

Browse files
committed
fix(#100): supported file type logic should be case-insensitive
1 parent c12567d commit b259f88

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

internal/images/image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func GetEXIFValues(path string) (map[string]string, error) {
120120
}
121121

122122
func extToFormat(ext string) imagemeta.ImageFormat {
123-
switch ext {
123+
switch strings.ToLower(ext) {
124124
case ".jpg", ".jpeg":
125125
return imagemeta.JPEG
126126
case ".webp":

internal/images/image_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ func TestGetImageEXIF(t *testing.T) {
135135
assert.Equal(t, testdata.ExpectedExposureTime, exif["ExposureTime"])
136136
assert.Equal(t, testdata.ExpectedISO, exif["ISO"])
137137
assert.Equal(t, testdata.ExpectedApertureValue, exif["ApertureValue"])
138+
139+
exif, err = GetEXIFValues(testdata.MetadataTestFileUpperCase)
140+
assert.Nil(t, err)
138141
}
139142

140143
func TestGetEmptyImageDescription(t *testing.T) {

internal/testdata/testdata.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,14 @@ var (
144144
)
145145

146146
var (
147-
MetadataTestFile = "../../testdata/exif/test.jpg"
148-
ExpectedImageDescription = "A brand new description"
149-
ExpectedMake = "FUJIFILM"
150-
ExpectedModel = "GFX 50R"
151-
ExpectedExposureTime = "1/340"
152-
ExpectedISO = "100"
153-
ExpectedApertureValue = "8"
147+
MetadataTestFile = "../../testdata/exif/test.jpg"
148+
MetadataTestFileUpperCase = "../../testdata/exif/test.JPG"
149+
ExpectedImageDescription = "A brand new description"
150+
ExpectedMake = "FUJIFILM"
151+
ExpectedModel = "GFX 50R"
152+
ExpectedExposureTime = "1/340"
153+
ExpectedISO = "100"
154+
ExpectedApertureValue = "8"
154155

155156
PngMetadataTestFile = "../../testdata/exif/test.png"
156157
PngExpectedImageDescription = "A png new description"

0 commit comments

Comments
 (0)