mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-09 17:22:21 +08:00
Implements path.IsJustAKey().
License: MIT Signed-off-by: Stephen Whitmore <noffle@ipfs.io>
This commit is contained in:
@ -44,6 +44,12 @@ func (p Path) String() string {
|
||||
return string(p)
|
||||
}
|
||||
|
||||
// IsJustAKey returns true if the path is of the form <key> or /ipfs/<key>.
|
||||
func (p Path) IsJustAKey() bool {
|
||||
parts := p.Segments()
|
||||
return (len(parts) == 2 && parts[0] == "ipfs")
|
||||
}
|
||||
|
||||
func FromSegments(prefix string, seg ...string) (Path, error) {
|
||||
return ParsePath(prefix + strings.Join(seg, "/"))
|
||||
}
|
||||
|
Reference in New Issue
Block a user