https://github.com/bruno-garcia/shortr
URL shortener and redirection
https://github.com/bruno-garcia/shortr
aspnetcore library shorten-urls
Last synced: 11 months ago
JSON representation
URL shortener and redirection
- Host: GitHub
- URL: https://github.com/bruno-garcia/shortr
- Owner: bruno-garcia
- Created: 2020-01-02T22:36:31.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-09T15:29:46.000Z (about 2 years ago)
- Last Synced: 2024-12-16T11:46:34.572Z (over 1 year ago)
- Topics: aspnetcore, library, shorten-urls
- Language: C#
- Homepage:
- Size: 64.5 KB
- Stars: 12
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# shortr
[](https://travis-ci.org/bruno-garcia/shortr/builds/632765857)
[](https://ci.appveyor.com/project/bruno-garcia/shortr)
[](https://ci.appveyor.com/project/bruno-garcia/shortr/branch/master/tests)
[](https://codecov.io/gh/bruno-garcia/shortr)
[](https://www.codacy.com/manual/bruno-garcia/shortr?utm_source=github.com&utm_medium=referral&utm_content=bruno-garcia/shortr&utm_campaign=Badge_Grade)
| Package | NuGet |
| ----------------------------- | :-------------------: |
| **Shortr** | [](https://www.nuget.org/packages/Shortr) | [](https://www.nuget.org/packages/Shortr) |
| **Shortr.AspNetCore** | [](https://www.nuget.org/packages/Shortr.AspNetCore) | [](https://www.nuget.org/packages/Shortr.AspNetCore) |
| **Shortr.Npgsql** | [](https://www.nuget.org/packages/Shortr.Npgsql) | [](https://www.nuget.org/packages/Shortr.Npgsql) |
## A .NET Library for URL shortening and request redirection
This project can create short URLs (i.e: [https://nugt.net/s/FqJFMC2](https://nugt.net/s/FqJFMC2)) and redirect requests to the original URL.
You can see it in use [in the NuGetTrends source code](https://github.com/NuGetTrends/nuget-trends).
### How does it work
It offers an in-memory store, for testing. And a [Postgres extension package](https://github.com/bruno-garcia/shortr/tree/master/src/Shortr.Npgsql)
and an [ASP.NET Core extension](https://github.com/bruno-garcia/shortr/tree/master/src/Shortr.AspNetCore) to plug it into the request pipeline.
It also includes a [web app](https://github.com/bruno-garcia/shortr/tree/master/src/Shortr.Web) to demonstrate its use from a JavaScript client.
### Configuration
By default it only generates links to URLs sharing the same `BaseAddress` as configured for the application itself.
It's possible to change this behavior in different ways.
For example, allowing a direct URL to be created to any destination:
```csharp
var options = new ShortrOptions
{
AllowRedirectToAnyDomain = true
}
```
The other [options can be found here](https://github.com/bruno-garcia/shortr/blob/master/src/Shortr/ShortrOptions.cs).
### Run the Web project
Make sure you have [.NET Core 3](https://dot.net), `docker` and `docker-compose` to run `PostgreSQL`:
1. Start postgres with `docker-compose up`
2. Navigate to `src\Shortr.Web` and run `dotnet run`
3. Browser `http://localhost:5000`