Skip to content

Commit 46e04b4

Browse files
committed
fix: rename retrieval to tag
1 parent 8e025e7 commit 46e04b4

File tree

5 files changed

+86
-88
lines changed

5 files changed

+86
-88
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"test:browser": "playwright-test --runner mocha 'test/**/!(*.node).test.js'"
2929
},
3030
"dependencies": {
31-
"@multiformats/multiaddr": "^12.4.0",
31+
"@vascosantos/multiaddr": "^12.4.2",
3232
"multiformats": "^13.3.6"
3333
},
3434
"devDependencies": {

pnpm-lock.yaml

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { CID } from 'multiformats/cid'
2-
import { Multiaddr } from '@multiformats/multiaddr'
2+
import { Multiaddr } from '@vascosantos/multiaddr'
33

44
export interface ProviderHint {
55
multiaddr: Multiaddr
6-
protos?: string[]
6+
tags?: string[]
77
}
88

99
export type { CID, Multiaddr }

src/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as API from './api.js'
22

3-
import { multiaddr, isMultiaddr } from '@multiformats/multiaddr'
3+
import { multiaddr, isMultiaddr } from '@vascosantos/multiaddr'
44
import { CID } from 'multiformats/cid'
55

66
/**
@@ -36,8 +36,8 @@ export function createUri({ base, path, providers = [] }) {
3636
const baseParts = provider.multiaddr.toString().split('/')
3737
const hintParts = [...baseParts]
3838

39-
for (const proto of provider.protos || []) {
40-
if (proto) hintParts.push('retrieval', proto)
39+
for (const tag of provider.tags || []) {
40+
if (tag) hintParts.push('tag', tag)
4141
}
4242

4343
const hint = '/' + hintParts.filter(Boolean).join('/')
@@ -49,7 +49,7 @@ export function createUri({ base, path, providers = [] }) {
4949

5050
/**
5151
* Parse a provider-hinted URI into a CID and structured provider hints,
52-
* preserving the full multiaddr including `/retrieval/<proto>` segments.
52+
* preserving the full multiaddr including `/tag/<tag-name>` segments.
5353
*
5454
* @param {string} uri
5555
* @returns {{ cid: API.CID, providers: API.ProviderHint[], path: string, protocol: string }}
@@ -85,13 +85,13 @@ export function parseQueryString(query) {
8585

8686
const protoParts = val.split('/').filter(Boolean)
8787
/** @type {string[]} */
88-
const protos = []
88+
const tags = []
8989

9090
for (let i = 0; i < protoParts.length; ) {
91-
if (protoParts[i] === 'retrieval') {
91+
if (protoParts[i] === 'tag') {
9292
i++
9393
if (i < protoParts.length) {
94-
protos.push(protoParts[i])
94+
tags.push(protoParts[i])
9595
i++
9696
}
9797
} else {
@@ -101,7 +101,7 @@ export function parseQueryString(query) {
101101

102102
try {
103103
const m = multiaddr(val)
104-
providers.push({ multiaddr: m, protos })
104+
providers.push({ multiaddr: m, tags })
105105
} catch {
106106
// Skip malformed multiaddrs
107107
continue

0 commit comments

Comments
 (0)