summaryrefslogtreecommitdiffhomepage
path: root/version/exename.go
blob: adb5236177e318005dd481858b48585f8e862eb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause

package version

import (
	"path/filepath"
	"strings"
)

// prepExeNameForCmp strips any extension and arch suffix from exe, and
// lowercases it.
func prepExeNameForCmp(exe, arch string) string {
	baseNoExt := strings.ToLower(strings.TrimSuffix(filepath.Base(exe), filepath.Ext(exe)))
	archSuffix := "-" + arch
	return strings.TrimSuffix(baseNoExt, archSuffix)
}

func checkPreppedExeNameForGUI(preppedExeName string) bool {
	return preppedExeName == "tailscale-ipn" || preppedExeName == "tailscale-gui"
}

func isGUIExeName(exe, arch string) bool {
	return checkPreppedExeNameForGUI(prepExeNameForCmp(exe, arch))
}