link

🔗 Parse, shorten and format links.

GitHub Workflow Status codecov.io Hex.pm Libraries.io dependency status contributions welcome HitCount

Why? 🤷‍♀️

We didn't find a link parsing library that did exactly what we needed so we wrote one.

What?

A micro library for parsing and formatting links for use in our App (currently in the MVP )

Note: the code is deliberately "basic". not at all "fancy" that is intentional so that it's understandable by a complete beginner to Elixir. 🔰 Simple code is maintainable and extensible without having to waste time Googling to figure it out. That said, if you want to help refactoring for performance, please open an issue.

Who? 👤

This library was created for us by us, the people using the @dwyl App.
We don't expect this to be used by anyone else because it's probably too specific to our use case. But if you need to parse links (URLs) in your project it might be link ... If you need a specific feature, please open an issue

How?

Use this package in your Elixir / Phoenix App!

Installation

Add link to your list of dependencies in your mix.exs file:

def deps do
[
{:link, "~> 1.0.1"}
]
end

Docs can be found at hexdocs.pm/link

Usage Examples 🔗

Here are a few examples we use in our MVP:

# Compact a GitHub issue URL so it doesn't waste screen space:
Link.compact("https://github.com/dwyl/mvp/issues/141")
> "dwyl/mvp#141"
# Strip the #issuecomment... from a GitHub issue URL:
Link.compact("https://github.com/dwyl/mvp/issues/141#issuecomment-1636209664")
> "dwyl/mvp#141"
# Shorten the link using Linky (interface TBD)
Link.shorten(conn, "https://github.com/dwyl/mvp/issues/141")
> "dwy.is/mvp-141

Need More? 🙌

If you need a specific function, please open an issue to discuss.