JSPM

js-ipld-url

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q53734F
  • License MIT

Parser and serializer for IPLD URLs in JavaScript

Package Exports

  • js-ipld-url

Readme

js-ipld-url

Parser and serializer for IPLD URLs in JavaScript

Works in the browser, Node.js 16+, and Deno 1.23+

Example

import IPLDURL, {IPLDURLSegment} from './ipldurl.js'

const url = new IPLDURL('ipld://examplecidhere/path;param1=value1/to/thing;param2;param3=value2/?queryparam=whatever

const segments = url.segments

segments === [{
  name: 'path',
  parameters: {param1: 'value1'}
}, {
  name: 'to'
}, {
  name: 'thing',
  parameters: {parm2:'', param3: 'value2'}
}]

// Set segments programmatically
url.segments = [{
  // Automatically escape special characters in the name
  name: 'escape;this',
  // Split up arrays into multiple params
  parameters: {whatever:[1,2,3]}
}, {
  name: '😁'
}]

url.href === 'ipld://examplecidhere/escape%3Bthis;whatever=1;whatever=2;whatever=3/%F0%9F%98%81?queryparam=whatever'