summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-12-10 16:22:08 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-12-12 21:43:17 +0100
commite293e7ca6dcc34cded7eb90a644b5c720c2179cf (patch)
treedee8e8d272660d23aa7b76576e8267fc70c34f78 /media
parent157d86414d43f6801e2a6996108f67d28679eac5 (diff)
downloadhugo-e293e7ca6dcc34cded7eb90a644b5c720c2179cf.tar.gz
hugo-e293e7ca6dcc34cded7eb90a644b5c720c2179cf.zip
Add js.Batch
Fixes #12626 Closes #7499 Closes #9978 Closes #12879 Closes #13113 Fixes #13116
Diffstat (limited to 'media')
-rw-r--r--media/mediaType.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/media/mediaType.go b/media/mediaType.go
index a7ba1309a..97b10879c 100644
--- a/media/mediaType.go
+++ b/media/mediaType.go
@@ -273,9 +273,13 @@ func (t Types) GetByType(tp string) (Type, bool) {
return Type{}, false
}
+func (t Types) normalizeSuffix(s string) string {
+ return strings.ToLower(strings.TrimPrefix(s, "."))
+}
+
// BySuffix will return all media types matching a suffix.
func (t Types) BySuffix(suffix string) []Type {
- suffix = strings.ToLower(suffix)
+ suffix = t.normalizeSuffix(suffix)
var types []Type
for _, tt := range t {
if tt.hasSuffix(suffix) {
@@ -287,7 +291,7 @@ func (t Types) BySuffix(suffix string) []Type {
// GetFirstBySuffix will return the first type matching the given suffix.
func (t Types) GetFirstBySuffix(suffix string) (Type, SuffixInfo, bool) {
- suffix = strings.ToLower(suffix)
+ suffix = t.normalizeSuffix(suffix)
for _, tt := range t {
if tt.hasSuffix(suffix) {
return tt, SuffixInfo{
@@ -304,7 +308,7 @@ func (t Types) GetFirstBySuffix(suffix string) (Type, SuffixInfo, bool) {
// is ambiguous.
// The lookup is case insensitive.
func (t Types) GetBySuffix(suffix string) (tp Type, si SuffixInfo, found bool) {
- suffix = strings.ToLower(suffix)
+ suffix = t.normalizeSuffix(suffix)
for _, tt := range t {
if tt.hasSuffix(suffix) {
if found {
@@ -324,7 +328,7 @@ func (t Types) GetBySuffix(suffix string) (tp Type, si SuffixInfo, found bool) {
}
func (t Types) IsTextSuffix(suffix string) bool {
- suffix = strings.ToLower(suffix)
+ suffix = t.normalizeSuffix(suffix)
for _, tt := range t {
if tt.hasSuffix(suffix) {
return tt.IsText()