Skip to content

Commit

Permalink
namesys: allow non /ipfs paths
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
  • Loading branch information
magik6k committed Oct 16, 2018
1 parent e335fd3 commit 462c802
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion namesys/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func resolveAsync(ctx context.Context, r resolver, name string, options opts.Res
return
}
log.Debugf("resolved %s to %s", name, res.value.String())
if strings.HasPrefix(res.value.String(), "/ipfs/") {
if !strings.HasPrefix(res.value.String(), ipnsPrefix) {
outCh <- Result{Path: res.value}
break
}
Expand Down
21 changes: 21 additions & 0 deletions test/sharness/t0100-name.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,27 @@ test_expect_success "publish an explicit node ID as key name looks good" '
test_cmp expected_node_id_publish actual_node_id_publish
'

# test IPNS + IPLD
test_expect_success "'ipfs dag put' succeeds" '
HELLO_HASH="$(echo "\"hello world\"" | ipfs dag put)" &&
OBJECT_HASH="$(echo "{\"thing\": {\"/\": \"${HELLO_HASH}\" }}" | ipfs dag put)"
'
test_expect_success "'ipfs name publish --allow-offline /ipld/...' succeeds" '
PEERID=`ipfs id --format="<id>"` &&
test_check_peerid "${PEERID}" &&
ipfs name publish --allow-offline "/ipld/$OBJECT_HASH/thing" >publish_out
'
test_expect_success "publish a path looks good" '
echo "Published to ${PEERID}: /ipld/$OBJECT_HASH/thing" >expected3 &&
test_cmp expected3 publish_out
'
test_expect_success "'ipfs name resolve' succeeds" '
ipfs name resolve "$PEERID" >output
'
test_expect_success "resolve output looks good" '
printf "/ipld/%s/thing\n" "$OBJECT_HASH" >expected4 &&
test_cmp expected4 output
'

# test publishing nothing

Expand Down

0 comments on commit 462c802

Please sign in to comment.