{"id":27118581,"url":"https://github.com/doga/iri","last_synced_at":"2025-10-28T16:03:35.335Z","repository":{"id":233307139,"uuid":"786952657","full_name":"doga/IRI","owner":"doga","description":"An IRI parser. Parses URLs and URNs.","archived":false,"fork":false,"pushed_at":"2025-04-05T20:00:12.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T20:30:01.862Z","etag":null,"topics":["i18n","l10n","parser-library","runnable-readme","unicode-support","web-development"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doga.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-15T16:00:11.000Z","updated_at":"2025-04-05T20:00:15.000Z","dependencies_parsed_at":"2025-03-12T09:15:17.601Z","dependency_job_id":null,"html_url":"https://github.com/doga/IRI","commit_stats":null,"previous_names":["doga/iri"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doga%2FIRI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doga%2FIRI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doga%2FIRI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doga%2FIRI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doga","download_url":"https://codeload.github.com/doga/IRI/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247615461,"owners_count":20967183,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["i18n","l10n","parser-library","runnable-readme","unicode-support","web-development"],"created_at":"2025-04-07T07:58:54.518Z","updated_at":"2025-10-28T16:03:35.327Z","avatar_url":"https://github.com/doga.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Parser for Internationalized Resource Identifier\n\nA parser for [IRI](https://en.wikipedia.org/wiki/Internationalized_Resource_Identifier)s.\n\n## How this works\n\nParsing an `IRI` produces either an `IRL` or an `URN`. `IRL` is a non-standard representation of a `URL` that this library introduces, as it is very useful. An `IRL` object:\n\n- keeps the URL in its original Unicode form (i.e. `https://çağlayan.info/user/çağlayan/`), without projecting the URL string into ASCII space as the URL specification requires.\n- nevertheless makes the standards-compliant representation of the URL available through its `url` property (i.e. `https://xn--alayan-vua36b.info/user/%C3%A7a%C4%9Flayan/`).\n\nThis library provides a tagged template parser named `iri`, which is generally all that is needed to parse an `IRI`:\n\n```javascript\nimport { iri } from 'https://esm.sh/gh/doga/IRI@3.1.4/mod.mjs';\n\nconst\nhost  = 'localhost',\nanIri = iri`http://${host}`; // an IRL instance\n```\n\nThis library provides other classes and tagged template parsers as well, as shown in the detailed usage example below.\n\n## Usage example\n\n\u003cdetails data-mdrb\u003e\n\u003csummary\u003eParse IRIs.\u003c/summary\u003e\n\n\u003cpre\u003e\ndescription = '''\nShows how to use this library for parsing IRIs.\n'''\n\u003c/pre\u003e\n\u003c/details\u003e\n\n```javascript\nimport { IriParser, IRI, IRL, URN, iri, irl, url, urn } from 'https://esm.sh/gh/doga/IRI@3.1.4/mod.mjs';\n\nconst\niris = [\n  iri`https://çağlayan.info/user/çağlayan/?çağlayan#çağlayan`, // IRL\n  IriParser.parse('https://çağlayan.info/user/çağlayan/?çağlayan#çağlayan'), // IRL\n  iri``, // null\n\n  irl`https://çağlayan.info/user/çağlayan/`, // IRL\n  irl`https://xn--alayan-vua36b.info/user/%C3%A7a%C4%9Flayan/`, // IRL\n  new IRL('https://çağlayan.info/user/çağlayan/'), // IRL\n\n  url`https://xn--alayan-vua36b.info/user/%C3%A7a%C4%9Flayan/`, // URL\n  IriParser.parse('https://xn--alayan-vua36b.info/user/%C3%A7a%C4%9Flayan/'), // IRL\n\n  urn`urn:ietf:rfc:2648`, // URN\n  IriParser.parse('urn:ietf:rfc:2648'), // URN\n];\n\nfor (const iri1 of iris){\n  if(!iri1)continue;\n  if (iri1 instanceof URN) {\n    console.group(`URN: ${iri1}`);\n    console.info(`\n      namespace         👉 ${iri1.namespace}\n      namespaceSpecific 👉 ${iri1.namespaceSpecific}\n      resolver          👉 ${iri1.resolver}\n      query             👉 ${iri1.query}\n      fragment          👉 ${iri1.fragment}\n    `);\n    console.groupEnd();\n  } else if (iri1 instanceof URL) {\n    console.group(`URL: ${iri1}`);\n    console.info(`\n    URL:\n      origin   👉 ${iri1.origin}\n      hostname 👉 ${iri1.hostname}\n      host     👉 ${iri1.host}\n      pathname 👉 ${iri1.pathname}\n      hash     👉 ${iri1.hash}\n      search   👉 ${iri1.search}\n    `);\n    console.groupEnd();\n  } else if (iri1 instanceof IRL) { // URL with Unicode characters\n    console.group(`IRL: ${iri1}`);\n    console.info(`\n    IRL:\n      origin   👉 ${iri1.origin}\n      hostname 👉 ${iri1.hostname}\n      host     👉 ${iri1.host}\n      pathname 👉 ${iri1.pathname}\n      hash     👉 ${iri1.hash}\n      search   👉 ${iri1.search}\n\n    URL:\n      origin   👉 ${iri1.url.origin}\n      hostname 👉 ${iri1.url.hostname}\n      host     👉 ${iri1.url.host}\n      pathname 👉 ${iri1.url.pathname}\n      hash     👉 ${iri1.url.hash}\n      search   👉 ${iri1.url.search}\n    `);\n    console.groupEnd();\n  }\n}\n```\n\nSample output for the code above:\n\n```text\nstep 1 of 1 // Parse IRIs using tagged templates.\n\nIRL: https://çağlayan.info/user/çağlayan/?çağlayan#çağlayan\n    \n        IRL:\n          origin   👉 https://çağlayan.info\n          hostname 👉 çağlayan.info\n          host     👉 çağlayan.info\n          pathname 👉 /user/çağlayan/\n          hash     👉 #çağlayan\n          search   👉 ?çağlayan\n    \n        URL:\n          origin   👉 https://xn--alayan-vua36b.info\n          hostname 👉 xn--alayan-vua36b.info\n          host     👉 xn--alayan-vua36b.info\n          pathname 👉 /user/%C3%A7a%C4%9Flayan/\n          hash     👉 #%C3%A7a%C4%9Flayan\n          search   👉 ?%C3%A7a%C4%9Flayan\n        \nIRL: https://çağlayan.info/user/çağlayan/?çağlayan#çağlayan\n    \n        IRL:\n          origin   👉 https://çağlayan.info\n          hostname 👉 çağlayan.info\n          host     👉 çağlayan.info\n          pathname 👉 /user/çağlayan/\n          hash     👉 #çağlayan\n          search   👉 ?çağlayan\n    \n        URL:\n          origin   👉 https://xn--alayan-vua36b.info\n          hostname 👉 xn--alayan-vua36b.info\n          host     👉 xn--alayan-vua36b.info\n          pathname 👉 /user/%C3%A7a%C4%9Flayan/\n          hash     👉 #%C3%A7a%C4%9Flayan\n          search   👉 ?%C3%A7a%C4%9Flayan\n        \nIRL: https://çağlayan.info/user/çağlayan/\n    \n        IRL:\n          origin   👉 https://çağlayan.info\n          hostname 👉 çağlayan.info\n          host     👉 çağlayan.info\n          pathname 👉 /user/çağlayan/\n          hash     👉 \n          search   👉 \n    \n        URL:\n          origin   👉 https://xn--alayan-vua36b.info\n          hostname 👉 xn--alayan-vua36b.info\n          host     👉 xn--alayan-vua36b.info\n          pathname 👉 /user/%C3%A7a%C4%9Flayan/\n          hash     👉 \n          search   👉 \n        \nIRL: https://çağlayan.info/user/çağlayan/\n    \n        IRL:\n          origin   👉 https://çağlayan.info\n          hostname 👉 çağlayan.info\n          host     👉 çağlayan.info\n          pathname 👉 /user/çağlayan/\n          hash     👉 \n          search   👉 \n    \n        URL:\n          origin   👉 https://xn--alayan-vua36b.info\n          hostname 👉 xn--alayan-vua36b.info\n          host     👉 xn--alayan-vua36b.info\n          pathname 👉 /user/%C3%A7a%C4%9Flayan/\n          hash     👉 \n          search   👉 \n        \nIRL: https://çağlayan.info/user/çağlayan/\n    \n        IRL:\n          origin   👉 https://çağlayan.info\n          hostname 👉 çağlayan.info\n          host     👉 çağlayan.info\n          pathname 👉 /user/çağlayan/\n          hash     👉 \n          search   👉 \n    \n        URL:\n          origin   👉 https://xn--alayan-vua36b.info\n          hostname 👉 xn--alayan-vua36b.info\n          host     👉 xn--alayan-vua36b.info\n          pathname 👉 /user/%C3%A7a%C4%9Flayan/\n          hash     👉 \n          search   👉 \n        \nURL: https://xn--alayan-vua36b.info/user/%C3%A7a%C4%9Flayan/\n    \n        URL:\n          origin   👉 https://xn--alayan-vua36b.info\n          hostname 👉 xn--alayan-vua36b.info\n          host     👉 xn--alayan-vua36b.info\n          pathname 👉 /user/%C3%A7a%C4%9Flayan/\n          hash     👉 \n          search   👉 \n        \nIRL: https://çağlayan.info/user/çağlayan/\n    \n        IRL:\n          origin   👉 https://çağlayan.info\n          hostname 👉 çağlayan.info\n          host     👉 çağlayan.info\n          pathname 👉 /user/çağlayan/\n          hash     👉 \n          search   👉 \n    \n        URL:\n          origin   👉 https://xn--alayan-vua36b.info\n          hostname 👉 xn--alayan-vua36b.info\n          host     👉 xn--alayan-vua36b.info\n          pathname 👉 /user/%C3%A7a%C4%9Flayan/\n          hash     👉 \n          search   👉 \n        \nURN: urn:ietf:rfc:2648\n    \n          namespace         👉 ietf\n          namespaceSpecific 👉 rfc:2648\n          resolver          👉 undefined\n          query             👉 undefined\n          fragment          👉 undefined\n        \nURN: urn:ietf:rfc:2648\n    \n          namespace         👉 ietf\n          namespaceSpecific 👉 rfc:2648\n          resolver          👉 undefined\n          query             👉 undefined\n          fragment          👉 undefined\n        \n```\n\n### Running the usage example\n\nRun the example above by typing this in your terminal (requires [Deno](https://deno.com/) 2+):\n\n```shell\ndeno run --allow-net --allow-run --allow-env --allow-read jsr:@andrewbrey/mdrb@3.0.4 --dax=false --mode=isolated 'https://raw.githubusercontent.com/doga/IRI/master/README.md'\n```\n\n## Class diagram\n\n```mermaid\n---\ntitle: Class diagram\n---\n\nclassDiagram\n  class URL {\n    +string host\n    +string pathname\n    ...\n  }\n\n  note for IRL \"𝘜𝘯𝘪𝘤𝘰𝘥𝘦 𝘳𝘦𝘱𝘳𝘦𝘴𝘦𝘯𝘵𝘢𝘵𝘪𝘰𝘯 𝘰𝘧 𝘢 𝘜𝘙𝘓.\"\n  class IRL {\n    +URL url\n    +string host\n    +string pathname\n    ...\n  }\n  IRL *-- URL : has property\n\n\n  class URN{\n    +string namespace\n    +string namespaceSpecific\n    ...\n  }\n\n  class IriParser {\n    +parse() IRI$\n  }\n  IriParser ..\u003e IRL : depends on\n  IriParser ..\u003e URN : depends on\n\n  class IRI {\n    +string str\n    +toString() string\n    +equals(other) boolean\n  }\n\n  IRI \u003c|-- URN : extends\n  IRI \u003c|-- IRL : extends\n```\n\nBesides these classes, this library also provides the tagged template parsers `iri`, `irl`, `url`, and `urn`.\n\n∎\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoga%2Firi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoga%2Firi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoga%2Firi/lists"}