{"id":13646151,"url":"https://github.com/lambdaisland/uri","last_synced_at":"2025-05-16T07:04:07.277Z","repository":{"id":17885477,"uuid":"82917932","full_name":"lambdaisland/uri","owner":"lambdaisland","description":"A pure Clojure/ClojureScript URI library","archived":false,"fork":false,"pushed_at":"2024-01-24T06:41:51.000Z","size":145,"stargazers_count":246,"open_issues_count":5,"forks_count":21,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-07T17:21:53.369Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lambdaisland.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2017-02-23T10:53:49.000Z","updated_at":"2025-04-30T04:01:04.000Z","dependencies_parsed_at":"2024-01-05T12:25:44.781Z","dependency_job_id":"53d5cbac-c92c-4df1-b2d3-0bbb6e6011dd","html_url":"https://github.com/lambdaisland/uri","commit_stats":{"total_commits":131,"total_committers":21,"mean_commits":6.238095238095238,"dds":0.2290076335877863,"last_synced_commit":"4ad41063da205fbce2ed428f55f90595942f8613"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaisland%2Furi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaisland%2Furi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaisland%2Furi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaisland%2Furi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lambdaisland","download_url":"https://codeload.github.com/lambdaisland/uri/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254485053,"owners_count":22078767,"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":[],"created_at":"2024-08-02T01:02:49.482Z","updated_at":"2025-05-16T07:04:07.258Z","avatar_url":"https://github.com/lambdaisland.png","language":"Clojure","funding_links":["http://opencollective.com/lambda-island"],"categories":["Clojure"],"sub_categories":[],"readme":"# lambdaisland/uri\n\n\u003c!-- badges --\u003e\n[![CircleCI](https://circleci.com/gh/lambdaisland/uri.svg?style=svg)](https://circleci.com/gh/lambdaisland/uri) [![cljdoc badge](https://cljdoc.org/badge/lambdaisland/uri)](https://cljdoc.org/d/lambdaisland/uri) [![Clojars Project](https://img.shields.io/clojars/v/lambdaisland/uri.svg)](https://clojars.org/lambdaisland/uri)\n[![bb compatible](https://raw.githubusercontent.com/babashka/babashka/master/logo/badge.svg)](https://babashka.org)\n\u003c!-- /badges --\u003e\n\nA pure Clojure/ClojureScript URI library.\n\nKey features\n\n- 100% cross-platform `.cljc`\n- RFC compliant joining of URIs\n- relative URIs as first class citizens\n\n\u003c!-- opencollective --\u003e\n## Lambda Island Open Source\n\n\u003cimg align=\"left\" src=\"https://github.com/lambdaisland/open-source/raw/master/artwork/lighthouse_readme.png\"\u003e\n\n\u0026nbsp;\n\nuri is part of a growing collection of quality Clojure libraries created and maintained\nby the fine folks at [Gaiwan](https://gaiwan.co).\n\nPay it forward by [becoming a backer on our Open Collective](http://opencollective.com/lambda-island),\nso that we may continue to enjoy a thriving Clojure ecosystem.\n\nYou can find an overview of our projects at [lambdaisland/open-source](https://github.com/lambdaisland/open-source).\n\n\u0026nbsp;\n\n\u0026nbsp;\n\u003c!-- /opencollective --\u003e\n\n## Rationale\n\nThere are a number of Clojure libraries for working with URI/URLs (see\n[Similar projects](#similar-projects) below). They all rely to some degree on\n`java.net.URI` or `java.net.URL`. This lib provides a pure-Clojure/ClojureScript\nalternative.\n\nSee the [announcement blog post](https://lambdaisland.com/blog/27-02-2017-announcing-lambdaisland-uri)\n\n## Installation\n\nTo install, add the following dependency to your project or build file:\n\ndeps.edn:\n\n``` clojure\nlambdaisland/uri {:mvn/version \"1.19.155\"}\n```\n\nproject.clj\n\n``` clojure\n[lambdaisland/uri \"1.19.155\"]\n```\n\n## Usage\n\n``` clojure\n(require '[lambdaisland.uri :refer [uri join]])\n\n\n;; uri :: String -\u003e lambdaisland.uri.URI\n(uri \"//example.com/foo/bar\")\n;;=\u003e #lambdaisland/uri \"//example.com/foo/bar\"\n\n\n;; A URI is a record, use assoc to update specific parts\n;; Use `str` if you want the URI back as a string\n(str\n (assoc (uri \"//example.com/foo/bar\")\n        :scheme \"https\"\n        :user \"arne\"\n        :password \"supersecret\"\n        :host \"lambdaisland.com\"\n        :port \"3333\"\n        :path \"/hello/world\"\n        :query \"q=5\"\n        :fragment \"section1\"))\n;;=\u003e \"https://arne:supersecret@lambdaisland.com:3333/hello/world?q=5#section1\"\n\n\n;; RFC compliant joining of relative URIs\n(join \"//example.com/foo/bar\" \"./~arne/site/\" \"../foo.png\")\n;;=\u003e #lambdaisland/uri \"//example.com/foo/~arne/foo.png\"\n\n\n;; Arguments to `join` are coerced, you can pass strings, java.net.URI, or any x\n;; for which `(str x)` returns a URI string.\n(join (java.net.URI. \"http://example.com/foo/bar\")  (uri \"./~arne/site/\") \"../foo.png\")\n;;=\u003e #lambdaisland/uri \"http://example.com/foo/~arne/foo.png\"\n\n\n;; URI implements IFn for keyword based lookup, so it's fully\n;; interface-compatible with Clojure maps.\n(:path (uri \"http://example.com/foo/bar\"))\n\n;; Provide custom ordering for query-map\n;; clj -Sdeps '{:deps {org.flatland/ordered {:mvn/version \"1.5.7\"}}}'\n(require '[lambdaisland.uri :refer [query-map]]\n         '[flatland.ordered.map :refer [ordered-map]])\n(keys (query-map \"http://example.com?a=1\u0026b=2\u0026c=3\u0026d=4\u0026e=5\u0026f=6\u0026g=7\u0026h=8\u0026i=9\"\n                 {:into (ordered-map)}))\n=\u003e (:a :b :c :d :e :f :g :h :i)\n\n;; Instances of URI are printed with a #lambdaisland/uri reader tag. To read\n;; them back from EDN, use the provided readers.\n(require '[clojure.edn :as edn])\n\n(edn/read-string\n {:readers lambdaisland.uri/edn-readers}\n \"#lambdaisland/uri \\\"http://example.com/foo/~arne/foo.png\\\"\")\n```\n\n[Full API docs are on Cljdoc](https://cljdoc.org/d/lambdaisland/uri)\n\n## Babashka-specific caveats (also applies to SCI)\n\nInstances of URI implement the `toString` method, so calling `(str uri)` gives\nyou the URI back as a string. They also implement the `IFn` interfaces so they\nare callable the way maps are.\n\nOn babashka implementing interfaces or overriding Object methods is not\nsupported. As an alternative to `clojure.core/str` you can use\n`lambdaisland.uri/uri-str`. As an alternative to using the URI as a function, use the keyword as a function, or use `clojure.core/get`\n\n``` clojure\n;; clojure / clojurescript\n(str uri) ;; \"https://example.com\"\n(uri :host) ;; \"example.com\"\n\n;; bb\n(str uri) ;; \"{:scheme \"https\", :domain \"example.com\", :path ...}\"\n(uri :host) ;; nil\n\n(uri/uri-str uri) ;; \"https://example.com\"\n(:host uri) ;; \"example.com\"\n(get uri :host) ;; \"example.com\"\n```\n\n## Similar projects\n\n* [exploding-fish](https://github.com/wtetzner/exploding-fish)\n  I was not aware at the time of creating lambdaisland/uri of exploding fish. It\n  is the most mature pure-Clojure URI lib out there. It does not provide\n  ClojureScript support.\n* [cemerick/url](https://github.com/cemerick/url)\n  Cross platform (cljx), Clojure version uses `java.net.URL`.\n* [michaelklishin/urly](https://github.com/michaelklishin/urly)\n  Based on `java.net.URI`.\n* [codonnell/uri](https://github.com/codonnell/uri)\n  Based on `java.net.URI`.\n\n## Further reading\n\n[RFC3986 Uniform Resource Identifier (URI): Generic Syntax](https://www.ietf.org/rfc/rfc3986.txt)\n\nThis library implements the algorithm specified in [Section 5.2](https://tools.ietf.org/html/rfc3986#section-5.2) of that RFC.\n\nIt has been tested against [this list of test cases compiled by the W3C](https://www.w3.org/2004/04/uri-rel-test.html).\n\n\u003c!-- contributing --\u003e\n## Contributing\n\nEveryone has a right to submit patches to uri, and thus become a contributor.\n\nContributors MUST\n\n- adhere to the [LambdaIsland Clojure Style Guide](https://nextjournal.com/lambdaisland/clojure-style-guide)\n- write patches that solve a problem. Start by stating the problem, then supply a minimal solution. `*`\n- agree to license their contributions as MPL 2.0.\n- not break the contract with downstream consumers. `**`\n- not break the tests.\n\nContributors SHOULD\n\n- update the CHANGELOG and README.\n- add tests for new functionality.\n\nIf you submit a pull request that adheres to these rules, then it will almost\ncertainly be merged immediately. However some things may require more\nconsideration. If you add new dependencies, or significantly increase the API\nsurface, then we need to decide if these changes are in line with the project's\ngoals. In this case you can start by [writing a pitch](https://nextjournal.com/lambdaisland/pitch-template),\nand collecting feedback on it.\n\n`*` This goes for features too, a feature needs to solve a problem. State the problem it solves, then supply a minimal solution.\n\n`**` As long as this project has not seen a public release (i.e. is not on Clojars)\nwe may still consider making breaking changes, if there is consensus that the\nchanges are justified.\n\u003c!-- /contributing --\u003e\n\n\u003c!-- license-mpl --\u003e\n## License\n\nCopyright \u0026copy; 2017-2021 Arne Brasseur and Contributors\n\nLicensed under the term of the Mozilla Public License 2.0, see LICENSE.\n\u003c!-- /license-mpl --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambdaisland%2Furi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flambdaisland%2Furi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambdaisland%2Furi/lists"}