mirror of
https://github.com/gogrlx/snack.git
synced 2026-04-02 05:08:42 -07:00
- Add brew package for Homebrew support on macOS and Linux - Implement NameNormalizer interface (NormalizeName, ParseArch) for all providers - Add darwin platform detection with Homebrew as default - Consolidate capabilities by removing separate *_linux.go/*_other.go files - Update tests for new capability expectations - Add comprehensive tests for AUR and brew providers - Update README with capability matrix and modern Target API usage 💘 Generated with Crush Assisted-by: AWS Claude Opus 4.5 via Crush <crush@charm.land>
30 lines
813 B
Go
30 lines
813 B
Go
package flatpak
|
|
|
|
import "strings"
|
|
|
|
// normalizeName returns the canonical form of a flatpak application ID.
|
|
// Flatpak references can include branch/arch suffixes like:
|
|
// - org.gnome.Calculator/x86_64/stable
|
|
// - org.gnome.Calculator//stable (default arch)
|
|
//
|
|
// This strips branch and arch to return just the app ID.
|
|
func normalizeName(name string) string {
|
|
n, _ := parseRef(name)
|
|
return n
|
|
}
|
|
|
|
// parseRef extracts the architecture from a flatpak reference if present.
|
|
// Flatpak references can be in the form:
|
|
// - app-id
|
|
// - app-id/arch/branch
|
|
// - app-id//branch (default arch)
|
|
//
|
|
// Returns the app-id and architecture (or empty string).
|
|
func parseRef(name string) (string, string) {
|
|
parts := strings.SplitN(name, "/", 3)
|
|
if len(parts) >= 2 {
|
|
return parts[0], parts[1]
|
|
}
|
|
return name, ""
|
|
}
|