Skip to content

Commit ad5fc09

Browse files
committed
fix: application/x-mpegURL content-type lookup
1 parent 3f9d789 commit ad5fc09

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

internal/pkg/postprocessor/extractor/m3u8.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func (M3U8Extractor) Extract(URL *models.URL) (assets []*models.URL, err error)
1717

1818
func IsM3U8(URL *models.URL) bool {
1919
mt := URL.GetMIMEType()
20+
// TODO: https://github.com/gabriel-vasile/mimetype/pull/755 remove "application/x-mpegURL" when merged&released
2021
return mt != nil && (mt.Is("application/vnd.apple.mpegurl") || mt.Is("application/x-mpegURL"))
2122
}
2223

internal/pkg/postprocessor/extractor/m3u8_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestShouldMatchM3U8URL(t *testing.T) {
3939
// call match, returns bool
4040
matched := M3U8Extractor{}.Match(&url)
4141
if matched != c.expected {
42-
t.Errorf("M3U8Extractor.Match(%q) = %v, want %v", c.url, matched, c.expected)
42+
t.Errorf("M3U8Extractor.Match(%q) = %v, want %v: mimetype=%q", c.url, matched, c.expected, url.GetMIMEType())
4343
}
4444
})
4545
}

pkg/models/mime_patch.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@ func extendMimetype() {
1818
// gabriel-vasile/mimetype does not support CSS detection yet, so
1919
// we have to extend a placeholder for our Content-Type lookup.
2020
mimetype.Lookup("text/plain").Extend(mimePlaceholderFunc, "text/css", ".css")
21+
22+
// TODO: https://github.com/gabriel-vasile/mimetype/pull/755, https://github.com/gabriel-vasile/mimetype/pull/756
23+
// TODO: Before the above PRs are merged and released, we have to extend a placeholder for application/x-mpegurl Content-Type lookup.
24+
mimetype.Lookup("application/vnd.apple.mpegurl").Extend(mimePlaceholderFunc, "application/x-mpegurl", ".m3u")
2125
})
2226
}

0 commit comments

Comments
 (0)