@cptpiepmatz/tag-uri@0.1.2Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
🏷️ RFC 4151 Tag URI parser and generator
@cptpiepmatz/tag-uri
RFC 4151 Tag URI parser and generator
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:[email protected],2001:web/externalHome"); // Access different parts of the tag URI expect(tag.get()).toBe("tag:[email protected],2001:web/externalHome"); expect(tag.authorityName).toBe("[email protected]"); 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: "[email protected]", dnsName: null, }, date: { year: "2001", month: null, day: null, }, specific: "web/externalHome", fragment: null, }); expect(tag.get()).toBe("tag:[email protected],2001:web/externalHome");
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
npx jsr add @cptpiepmatz/tag-uri
Import symbol
import * as tag_uri from "@cptpiepmatz/tag-uri";
Add Package
yarn dlx jsr add @cptpiepmatz/tag-uri
Import symbol
import * as tag_uri from "@cptpiepmatz/tag-uri";
Add Package
pnpm dlx 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";