{"id":15287996,"url":"https://github.com/mazingstudio/norma","last_synced_at":"2025-04-13T06:32:05.270Z","repository":{"id":50981126,"uuid":"106735690","full_name":"mazingstudio/norma","owner":"mazingstudio","description":"Normalize URLs to the format you need","archived":false,"fork":false,"pushed_at":"2022-08-01T17:48:40.000Z","size":32,"stargazers_count":22,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T23:11:21.473Z","etag":null,"topics":["elixir","elixir-lang","library"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/norma","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mazingstudio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-12T19:21:06.000Z","updated_at":"2023-09-01T10:59:17.000Z","dependencies_parsed_at":"2022-09-11T20:21:01.939Z","dependency_job_id":null,"html_url":"https://github.com/mazingstudio/norma","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazingstudio%2Fnorma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazingstudio%2Fnorma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazingstudio%2Fnorma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazingstudio%2Fnorma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mazingstudio","download_url":"https://codeload.github.com/mazingstudio/norma/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248513159,"owners_count":21116765,"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":["elixir","elixir-lang","library"],"created_at":"2024-09-30T15:43:42.552Z","updated_at":"2025-04-13T06:32:04.961Z","avatar_url":"https://github.com/mazingstudio.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Norma\n\n[![Hex.pm](https://img.shields.io/hexpm/v/norma.svg?style=flat-square)]()\n[![Hex.pm](https://img.shields.io/hexpm/l/norma.svg?style=flat-square)]()\n[![Hex.pm](https://img.shields.io/hexpm/dt/norma.svg?style=flat-square)]()\n[![Maintenance](https://img.shields.io/maintenance/yes/2020.svg?style=flat-square)]()\n[![GitHub issues](https://img.shields.io/github/issues/zuraguerra/dumballah.svg?style=flat-square)](https://github.com/mazingstudio/norma/issues)\n[![Travis](https://img.shields.io/travis/mazingstudio/norma.svg)]()\n\nNormalize URLs to the format you need.\n\n## Installation\n\nAdd `Norma` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    # get always the latest ñ___ñ\n    {:norma, \"\u003e= 0.0.0\"}\n  ]\nend\n```\n\n### Note on compatibility\n\nNorma depends heavily on the implementation of the `URI` module (part of the standard library), which was recently changed when adding [support for Erlang 20](https://github.com/elixir-lang/elixir/issues/5851). Use [the module history](https://github.com/elixir-lang/elixir/commits/master/lib/elixir/lib/uri.ex) as a guide if you encounter any weird error (specially if you suspect it's related to a regex).\n\n## Usage\n\n```elixir\niex\u003e Norma.normalize(\"mazing.studio\")\n\u003e \"http://mazing.studio\"\n\niex\u003e Norma.normalize_if_valid(\"mazing.studio\")\n\u003e {:ok, \"http://mazing.studio\"}\n\niex\u003e Norma.normalize_if_valid(\"mazing\")\n\u003e {:error, \"Not an URL.\"}\n\niex\u003e options = %{remove_fragment: true, force_root_path: true, remove_www: true}\niex\u003e Norma.normalize(\"//www.mazing.studio:1337/test#test\", options)\n\u003e \"http://mazing.studio/\"\n```\n\n### Options\n\n- Remove scheme:\n  ```elixir\n  iex\u003e Norma.normalize(\"https://mazing.studio\", %{remove_scheme: true})\n  \u003e \"mazing.studio\"\n  ```\n\n- Remove fragment:\n  ```elixir\n  iex\u003e Norma.normalize(\"https://mazing.studio#test\", %{remove_fragment: true})\n  \u003e \"https://mazing.studio\"\n  ```\n\n- Add trailing slash:\n  ```elixir\n  iex\u003e Norma.normalize(\"https://mazing.studio/test\", %{add_trailing_slash: true})\n  \u003e \"https://mazing.studio/test/\"\n  ```\n\n- Force root path:\n  ```elixir\n  iex\u003e Norma.normalize(\"https://mazing.studio/test\", %{force_root_path: true})\n  \u003e \"https://mazing.studio/\"\n  ```\n\n- Remove `www`:\n  ```elixir\n  iex\u003e Norma.normalize(\"https://www.mazing.studio\", %{remove_www: true})\n  \u003e \"https://mazing.studio\"\n\n- Downcase host:\n  ```elixir\n  iex\u003e Norma.normalize(\"https://EXAMPLE.COM/FAQS\", %{downcase_host: true})\n  \u003e \"https://example.com/FAQS\"\n  ```\n\n### With Ecto\n\n```elixir\ndef creation_changeset(params) do\n  norma_options = %{\n    remove_www: true,\n    force_root_path: true,\n    remove_fragment: true\n  }\n  %MyEntity{}\n  |\u003e cast(params, @fields)\n  |\u003e put_change(:url, Norma.normalize(params.url, norma_options))\nend\n```\n\n## Contributing\n\n### Adding options\n\n1. Add support for the option in `/lib/norma/normalizer.ex`. Prefer pattern matching and guards over `if`s and `case`s.\n2. Add a test in `/test/norma_test.exs`.\n2. Add documentation to the `README`.\n3. Send a PR 🎉\n\n### Maintainers\n\n- [Zura Guerra](https://github.com/ZuraGuerra) - [@grafofilia](https://twitter.com/grafofilia)\n\n---\n\n## A Mazing project\n\n![Mazing Studio](https://avatars3.githubusercontent.com/u/19610766?v=4\u0026s=200)\n\nSponsored by [_Mazing Studio_](https://mazing.studio)\n\nWe love to solve problems using Elixir and Go.\n\nHave a project you need help with? [Tell us about it!](https://mazing.studio/#section-form)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmazingstudio%2Fnorma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmazingstudio%2Fnorma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmazingstudio%2Fnorma/lists"}