tailscale/util/pathutil/pathutil.go
Percy Wegmann 857cef70c9
tailfs: initial implementation
Implemented WebDAV-based core of Tailfs

Updates tailscale/corp#16827

Signed-off-by: Percy Wegmann <percy@tailscale.com>
2024-02-02 12:33:48 -06:00

29 lines
585 B
Go

// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// package pathutil provides utility functions for working with URL paths.
package pathutil
import (
"path"
"strings"
)
const (
sepString = "/"
sepStringAndDot = "/."
sep = '/'
)
func Split(p string) []string {
return strings.Split(strings.Trim(path.Clean(p), sepStringAndDot), sepString)
}
func Join(parts ...string) string {
return sepString + strings.Join(parts, sepString)
}
func IsRoot(path string) bool {
return len(path) == 0 || len(path) == 1 && path[0] == sep
}