Skip to main content
Home

Built and signed on GitHub Actions

Works with
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score100%
Downloads18/wk
Publisheda year ago (0.1.2)

🏷️ RFC 4151 Tag URI parser and generator

@cptpiepmatz/tag-uri

RFC 4151 Tag URI parser and generator


JSR Version License

About

The main entry point and default export of this library is the TagUri class, which is all you’ll usually need. It simplifies working with RFC 4151 Tag URIs by parsing them into their components or allowing you to construct new ones programmatically.

Features

  • Parsing Tag URIs: Extract structured components like the authority name, date, and specific part.

  • Helpful Errors: Parsing failures include errors pointing to where the issue occurred.

  • Tag URI Construction: Create tag URIs using the TagUri constructor (note: validation is not yet implemented).

  • Platform Agnostic: Fully dependency-free, works with Deno, Node.js, and modern browsers using baseline web compatibility.

Usage

Parsing Tag URIs

import { TagUri } from "@cptpiepmatz/tag-uri";
import { expect } from "jsr:@std/expect";

// Parse a tag URI
const tag = TagUri.parse("tag:timothy@hpl.hp.com,2001:web/externalHome");

// Access different parts of the tag URI
expect(tag.get()).toBe("tag:timothy@hpl.hp.com,2001:web/externalHome");
expect(tag.authorityName).toBe("timothy@hpl.hp.com");
expect(tag.date).toBe("2001");
expect(tag.specific).toBe("web/externalHome");

Constructing Tag URIs

import { TagUri } from "@cptpiepmatz/tag-uri";
import { expect } from "jsr:@std/expect";

// Create a new tag URI
const tag = new TagUri({
  authorityName: {
    emailAddress: "timothy@hpl.hp.com",
    dnsName: null,
  },
  date: {
    year: "2001",
    month: null,
    day: null,
  },
  specific: "web/externalHome",
  fragment: null,
});

expect(tag.get()).toBe("tag:timothy@hpl.hp.com,2001:web/externalHome");
Built and signed on
GitHub Actions

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@cptpiepmatz/tag-uri

Import symbol

import * as tag_uri from "@cptpiepmatz/tag-uri";
or

Import directly with a jsr specifier

import * as tag_uri from "jsr:@cptpiepmatz/tag-uri";

Add Package

pnpm i jsr:@cptpiepmatz/tag-uri
or (using pnpm 10.8 or older)
pnpm dlx jsr add @cptpiepmatz/tag-uri

Import symbol

import * as tag_uri from "@cptpiepmatz/tag-uri";

Add Package

yarn add jsr:@cptpiepmatz/tag-uri
or (using Yarn 4.8 or older)
yarn dlx jsr add @cptpiepmatz/tag-uri

Import symbol

import * as tag_uri from "@cptpiepmatz/tag-uri";

Add Package

vlt install jsr:@cptpiepmatz/tag-uri

Import symbol

import * as tag_uri from "@cptpiepmatz/tag-uri";

Add Package

npx jsr add @cptpiepmatz/tag-uri

Import symbol

import * as tag_uri from "@cptpiepmatz/tag-uri";

Add Package

bunx jsr add @cptpiepmatz/tag-uri

Import symbol

import * as tag_uri from "@cptpiepmatz/tag-uri";