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

fix(rmlink): fix rmlink to match docs #4073

Merged
merged 1 commit into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/core-api/OBJECT.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,9 @@ An optional object which may have the following keys:
```JavaScript
// cid is CID of the DAG node created by removing a link
const cid = await ipfs.object.patch.rmLink(node, {
name: 'some-link',
size: 10,
cid: CID.parse('QmPTkMuuL6PD8L2SwTwbcs1NPg14U8mRzerB1ZrrBrkSDD')
Name: 'some-link',
Tsize: 10,
Hash: CID.parse('QmPTkMuuL6PD8L2SwTwbcs1NPg14U8mRzerB1ZrrBrkSDD')
})
```

Expand Down
6 changes: 3 additions & 3 deletions packages/ipfs-core/src/components/object/patch/rm-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export function createRmLink ({ repo, preload }) {
/**
* @type {import('ipfs-core-types/src/object/patch').API<{}>["rmLink"]}
*/
async function rmLink (multihash, linkRef, options = {}) {
const node = await get(multihash, options)
const name = (typeof linkRef === 'string' ? linkRef : linkRef.Name) || ''
async function rmLink (cid, link, options = {}) {
const node = await get(cid, options)
const name = (typeof link === 'string' ? link : link.Name) || ''

node.Links = node.Links.filter(l => l.Name !== name)

Expand Down