aboutsummaryrefslogtreecommitdiff
path: root/object/tree/path_prefix.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-30 05:40:58 +0000
committerGravatar Runxi Yu2026-03-30 05:44:56 +0000
commitaa7e2873aa4da53fbaa4774fdd33f5af20c1afb0 (patch)
tree0d1367f693324ea8287ccef52ba524f8515ca146 /object/tree/path_prefix.go
parentREADME, etc.: Use proper unicode hyphens :P (diff)
signatureNo signature
object/tree: Add helpers and cleanup v0.1.152
Diffstat (limited to 'object/tree/path_prefix.go')
-rw-r--r--object/tree/path_prefix.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/object/tree/path_prefix.go b/object/tree/path_prefix.go
new file mode 100644
index 00000000..ed658cee
--- /dev/null
+++ b/object/tree/path_prefix.go
@@ -0,0 +1,19 @@
+package tree
+
+import (
+ "bytes"
+ "slices"
+)
+
+// HasPathPrefix reports whether path begins with prefix as whole components.
+func HasPathPrefix(path, prefix [][]byte) bool {
+ if len(prefix) == 0 {
+ return true
+ }
+
+ if len(path) < len(prefix) {
+ return false
+ }
+
+ return slices.EqualFunc(path[:len(prefix)], prefix, bytes.Equal)
+}