Cleanup previous PR

This commit is contained in:
Kovid Goyal
2026-05-18 13:55:48 +05:30
parent 6e4e1c8edf
commit 6da5bae945
2 changed files with 34 additions and 34 deletions

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"container/list"
"context"
"encoding/base64"
"errors"
"fmt"
"io"
@@ -16,6 +15,8 @@ import (
"strconv"
"strings"
"github.com/emmansun/base64"
"github.com/kovidgoyal/go-parallel"
"github.com/kovidgoyal/kitty/tools/utils"
"github.com/kovidgoyal/kitty/tools/utils/streaming_base64"
@@ -376,40 +377,10 @@ type parsed_uri struct {
// ext_for_mime returns a file extension (with leading dot) for a MIME type.
func ext_for_mime(mime string) string {
switch mime {
case "image/jpeg":
return ".jpg"
case "image/png":
return ".png"
case "image/gif":
return ".gif"
case "image/webp":
return ".webp"
case "image/svg+xml":
return ".svg"
case "text/plain":
return ".txt"
case "text/html":
return ".html"
case "text/css":
return ".css"
case "application/pdf":
return ".pdf"
case "application/json":
return ".json"
case "application/zip":
return ".zip"
default:
if _, subtype, found := strings.Cut(mime, "/"); found && subtype != "" {
subtype, _, _ = strings.Cut(subtype, "+")
subtype, _, _ = strings.Cut(subtype, ";")
subtype = strings.TrimSpace(subtype)
if subtype != "" {
return "." + subtype
}
}
return ""
for _, x := range utils.GuessFileExtensions(mime) {
return x
}
return ""
}
// parse_data_uri decodes a data: URI and returns the MIME type and raw data.