Data structure containing the contents of a tag:
URI.
Instances of this class hold the data for tag:
URIs as defined by the
RFC 4151 or otherwise
described by taguri.org.
Getting an instance of this can either be done by manually constructing one
by passing all the necessary data into the constructor or by parsing
a tag:
URI string with parse
.
By using TagUri.prototype.get
, you can get the string
representation of the tag.
Other contained values can be accessed via the various getters.
Some getters may return null
as not every tag has to contain them
(e.g. the day
of the date
).
Get a instance via parse
Get a instance via parse
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");
[internal]: TagUriData
authorityName: string
Authority name of the tag:
URI.
Represents the authorityName
part of the RFC.
Day of the tag:
URI.
Represents the day
part of the RFC.
This value is nullable as date
might contain only a month and year or
only a year.
DNS name of the authority name of the tag:
URI.
Represents the DNSname
part of the RFC.
This value is nullable as authorityName
can be either a dns name or an
email address.
emailAddress: string | null
Email address of the authority name of the tag:
URI.
Represents the emailAddress
part of the RFC.
This value is nullable as authorityName
can be either a dns name or an
email address.
Fragment of the tag:
URI.
Represents the fragment
part of the RFC.
Might be an empty string as they are valid according to the RFC.
Might also be null
if the #
is omitted.
Month of the tag:
URI.
Represents the month
part of the RFC.
This value is nullable as date
might contain only a year.
The day
will then be also null
.
Specific of the tag:
URI.
Represents the specific
part of the RFC.
Might be an empty string as they are valid according to the RFC.
taggingEntity: string
Tagging entity of the tag:
URI.
Represents the taggingEntity
part of the RFC.
Compare two TagUri
instances for equality.
This does a equality check on all fields in the internal, deconstructed representation. This allows comparing two instances without getting the string representation first.
Get the string representation of this tag:
URI.
As the string is internally held in a deconstructed way, will this construct a new string every time this method is called.