Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 7af57c8

Browse files
Merge pull request #35 from apiarian/resolve-self
s.Resolve resolves node's IPNS on empty string
2 parents 0d08ad2 + daad01c commit 7af57c8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ipns.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,16 @@ func (s *Shell) Publish(node string, value string) error {
2424
return nil
2525
}
2626

27+
// Resolve gets resolves the string provided to an /ipfs/[hash]. If asked to
28+
// resolve an empty string, resolve instead resolves the node's own /ipns value.
2729
func (s *Shell) Resolve(id string) (string, error) {
28-
resp, err := s.newRequest("name/resolve", id).Send(s.httpcli)
30+
var resp *Response
31+
var err error
32+
if id != "" {
33+
resp, err = s.newRequest("name/resolve", id).Send(s.httpcli)
34+
} else {
35+
resp, err = s.newRequest("name/resolve").Send(s.httpcli)
36+
}
2937
if err != nil {
3038
return "", err
3139
}

0 commit comments

Comments
 (0)