diff options
| author | Percy Wegmann <percy@tailscale.com> | 2023-12-21 15:57:01 -0600 |
|---|---|---|
| committer | Percy Wegmann <percy@tailscale.com> | 2024-02-02 12:33:48 -0600 |
| commit | 857cef70c97fe019ea24f7b4f24252f4746ebcc3 (patch) | |
| tree | 257a7ec87af6ad29c06cdfe0e8774259f5e83cc3 /util/pathutil/pathutil.go | |
| parent | 60657ac83f415555c19027b0b18c0fe2d15bf40a (diff) | |
| download | tailscale-flyingsquirrel_bak.tar.xz tailscale-flyingsquirrel_bak.zip | |
tailfs: initial implementationflyingsquirrel_bak
Implemented WebDAV-based core of Tailfs
Updates tailscale/corp#16827
Signed-off-by: Percy Wegmann <percy@tailscale.com>
Diffstat (limited to 'util/pathutil/pathutil.go')
| -rw-r--r-- | util/pathutil/pathutil.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/util/pathutil/pathutil.go b/util/pathutil/pathutil.go new file mode 100644 index 000000000..6b3728d9f --- /dev/null +++ b/util/pathutil/pathutil.go @@ -0,0 +1,28 @@ +// 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 +} |
