IRI (Internationalized Resource Identifier)

IRI is a library for parsing URLs and URNs.

🏷 𝗘𝘅𝗮𝗺𝗽𝗹𝗲 How to parse a URL or URN.

import { iri, irl, urn, url, IRI, IRL, URN} from 'https://esm.sh/gh/doga/IRI@3.1.4/mod.mjs';
const
host = 'çağlayan.info',
irl1 = iri`https://${host}/résumé`, // an IRL (Unicode-aware variant of URL) and IRI instance
irl2 = irl`https://${host}/résumé`, // an IRL and IRI instance
url1 = irl1.url,                    // a URL instance
url2 = url`https://${host}/résumé`, // a URL instance
urn1 = iri`urn:ietf:rfc:3987`,      // a URN and IRI instance
urn2 = urn`urn:ietf:rfc:3987`;      // a URN and IRI instance
irl1.host;              // 'çağlayan.info'
irl1.url.host;          // 'xn--alayan-vua36b.info'
irl1.pathname;          // '/résumé'
irl1.url.pathname;      // '/r%C3%A9sum%C3%A9'
urn1.namespace;         // 'ietf'
urn1.namespaceSpecific; // 'rfc:3987'

🏷 𝗦𝗲𝗲

GitHub repository

🏷 𝗦𝗲𝗲

Internationalized Resource Identifier on Wikipedia

🏷 𝗦𝗲𝗲

RFC 3987: Internationalized Resource Identifiers (IRIs)

class IRI

equals(other)

🏷 𝗣𝗮𝗿𝗮𝗺𝗲𝘁𝗲𝗿 other: *

🏷 𝗥𝗲𝘁𝘂𝗿𝗻𝘀 boolean

toString()

🏷 𝗥𝗲𝘁𝘂𝗿𝗻𝘀 string

class IRL extends IRI

An "internationalised resource locator" (a Unicode version of a URL).

IRLs are non-standard but they should be, because they are a fix for URLs.

🏷 𝗦𝗲𝗲

URL

constructor(url, base)

Creates an IRL instance.

🏷 𝗣𝗮𝗿𝗮𝗺𝗲𝘁𝗲𝗿 url: *

🏷 𝗣𝗮𝗿𝗮𝗺𝗲𝘁𝗲𝗿 base: (URL|IRL|undefined)

🏷 𝗧𝗵𝗿𝗼𝘄𝘀 TypeError

class IriParser

An IRI parser.

🏷 𝗦𝗲𝗲

Internationalized Resource Identifier

static parse(iri, base)

Parses an IRI. All arguments will be stringified if they are not already strings.

🏷 𝗣𝗮𝗿𝗮𝗺𝗲𝘁𝗲𝗿 iri: *

🏷 𝗣𝗮𝗿𝗮𝗺𝗲𝘁𝗲𝗿 base: *

🏷 𝗥𝗲𝘁𝘂𝗿𝗻𝘀 IRI

🏷 𝗧𝗵𝗿𝗼𝘄𝘀 TypeError

class URN extends IRI

static regexp

Class property.

get fragment

get namespace

get namespaceSpecific

get query

get resolver

📅 𝑪𝒂𝒄𝒉𝒆𝒅 𝒐𝒏 𝑾𝒆𝒅 𝑫𝒆𝒄 𝟢𝟥 𝟤𝟢𝟤𝟧 𝟢𝟫:𝟤𝟨:𝟣𝟥 𝑮𝑴𝑻+𝟢𝟣𝟢𝟢 (𝑪𝒆𝒏𝒕𝒓𝒂𝒍 𝑬𝒖𝒓𝒐𝒑𝒆𝒂𝒏 𝑺𝒕𝒂𝒏𝒅𝒂𝒓𝒅 𝑻𝒊𝒎𝒆)