mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-02 14:56:38 +08:00
f2ab94501c
- Relocated go.mod and go.sum into backend/ root directory - Stripped redundant backend/ segments from all Go imports (github.com/Rain-kl/Wavelet/...) - Unified Makefile, swagger, and build-test to execute in backend/ module context - Ensured 100% build-test, code-check, format, and swagger pass
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package util
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/Rain-kl/Wavelet/plugins/domain/upload/shared"
|
|
)
|
|
|
|
// IsImageExtension reports whether ext is a common image format.
|
|
func IsImageExtension(ext string) bool {
|
|
for _, imgExt := range []string{"jpg", "jpeg", "png", "webp", "gif"} {
|
|
if ext == imgExt {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// IsArchiveExtension reports whether ext is a common archive format.
|
|
func IsArchiveExtension(ext string) bool {
|
|
for _, e := range []string{"zip", "rar", "7z", "tar", "gz", "tgz", "bz2", "xz"} {
|
|
if ext == e {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// IsDocumentExtension reports whether ext is a common document format.
|
|
func IsDocumentExtension(ext string) bool {
|
|
for _, e := range []string{"pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt", "md", "csv", "json", "yaml", "yml", "xml"} {
|
|
if ext == e {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// NormalizeImageQuality normalizes the requested image quality query parameter.
|
|
func NormalizeImageQuality(quality string) string {
|
|
q := strings.TrimSpace(strings.ToLower(quality))
|
|
switch q {
|
|
case shared.ImageQualityLow, shared.ImageQualityMedium, shared.ImageQualityHigh:
|
|
return q
|
|
default:
|
|
return shared.ImageQualityOrigin
|
|
}
|
|
}
|