Uuid-shortener - UUID shortening to any base, for usage in urls

Overview

UUIDShortener

Allow to shorten UUID, specially when using in URLs ; along with Vapor.

Usage

Import in Package.swift

...
dependencies: [
    ...
    // UUID Shortener ✂️
    .package(url: "https://github.com/Dean151/uuid-shortener", from: "1.0.0"),
    ...
],
targets: [
    .target(
        ...
        dependencies: [
            ...
            .product(name: "UUIDShortener", package: "uuid-shortener"),
            ...
        ],
        ...

Shorten & expand UUIDs

// Shorten any UUID
let uuid = UUID() // F0E07462-68F1-4219-96FE-D98C8449CAF0
let base32 = try uuid.shortened(using: .base32) // e9dlbzsyrie7pfu5hhx66b1m8
let base58 = try uuid.shortened(using: .base58) // vKbtaFgee2NLZVnLW6yuuq
let base62 = try uuid.shortened(using: .base62) // 7kwJxwyrgxEyZAKcDMFE1W
let base66 = try uuid.shortened(using: .base64) // 3MU7hyqf526pr-SoO4isHM
let base90 = try uuid.shortened(using: .base90) // n#g|6HlzuCBbxY~bho1!

// And get the original UUID back:
let original = try UUID(shortened: base62, using: .base62)

With Vapor 💧

You may use short identifiers in URL instead of using the full base16 UUID.

One of the best for URLs is base62 (no special characters), although base64 will work here.

If you need to disambiguate characters, base58 with alike characters stripped is best.

struct TodosController: RouteCollection {
    func boot(routes: RoutesBuilder) throws {
        routes.get("todo", ":identifier", use: getTodo)
    }

    private func getTodo(req: Request) throws -> EventLoopFuture<Todo> {
        guard let shortIdentifier = req.parameters.get("identifier"),
              let identifier = try? UUID(shortened: shortIdentifier, using: .base62) else {
            throw Abort(.badRequest, reason: "Missing or unparsable identifier")
        }
        return Todo.find(identifier, on: req.db)
            .unwrap(or: Abort(.notFound))
    }
    
    ...
}
You might also like...
Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more.
Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more.

IQKeyboardManager While developing iOS apps, we often run into issues where the iPhone keyboard slides up and covers the UITextField/UITextView. IQKey

Use any custom view as custom callout view for MKMapView with cool animations. Use any image as annotation view.
Use any custom view as custom callout view for MKMapView with cool animations. Use any image as annotation view.

MapViewPlus About MapViewPlus gives you the missing methods of MapKit which are: imageForAnnotation and calloutViewForAnnotationView delegate methods.

A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.

BadgeHub A way to quickly add a notification badge icon to any view. Demo/Example For demo: $ pod try BadgeHub To run the example project, clone the r

Automate box any value! Print log without any format control symbol! Change debug habit thoroughly!

LxDBAnything Automate box any value! Print log without any format control symbol! Change debug habit thoroughly! Installation You only need drag LxD

A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.

BadgeHub A way to quickly add a notification badge icon to any view. Demo/Example For demo: $ pod try BadgeHub To run the example project, clone the r

SwiftAudioPlayer - Swift-based audio player with AVAudioEngine as its base

SwiftAudioPlayer Swift-based audio player with AVAudioEngine as its base. Allows for: streaming online audio, playing local file, changing audio speed

Base types for theming an app.

CostumeKit 🎩 Base types for theming an app. CostumeKit is made of up a set of Swift protocols. They are meant to be implemented by you in your app. F

libuv base Swift web HTTP server framework

Notice Trevi now open a Trevi Community. Yoseob/Trevi project split up into respective Trevi, lime, middlewares and sys packages at our community. If

Uncomplicated cryptography frameworks base on CommonCrypto

Keys - Keys of data encryption 中文介绍 Example let password = Password("Secret") let key = SymmetricKey() password.encrypt(data) let data = "Hello Wo

Repository with base samples for playing HLS/DASH with CMAF video, across as many platforms as possible. Includes steps for encoding and packaging your own test content.

Video Everything Repository with minimal samples for playing HLS/DASH with CMAF video, across as many platforms as possible. Content and License All t

Turbo-iOS base project that's entirely driven from your backend Rails app.

Turbo-iOS base project that's entirely driven from your backend Rails app.

ARKit Base Project. Place virtual objects based on WWDC example project
ARKit Base Project. Place virtual objects based on WWDC example project

ARKit - Placing Virtual Objects in Augmented Reality Learn best practices for visual feedback, gesture interactions, and realistic rendering in AR exp

Base types for theming an app.

CostumeKit 🎩 Base types for theming an app. CostumeKit is made of up a set of Swift protocols. They are meant to be implemented by you in your app. F

Handles some of the base configuration to make creating a UIAlertController with text entry even easier. Plus validation!
Handles some of the base configuration to make creating a UIAlertController with text entry even easier. Plus validation!

🍅 FancyTextEntryController A simpler/easier API for adding text fields to UIAlertControllers. Not a custom view, just uses good ol' UIAlertController

RandMyMod base on your own struct or class create one or a set of instance, which the variable's value in the instance is automatic randomized.
RandMyMod base on your own struct or class create one or a set of instance, which the variable's value in the instance is automatic randomized.

RandMyMod is an IOS Native Framework helps you generate one or a set of variable base on your own model. No matter your model is Class / Struct. Insta

Projeto base de uma app de Delivery utilizado nas Sprints da Devpass.
Projeto base de uma app de Delivery utilizado nas Sprints da Devpass.

Delivery App Challenge 🍕 Neste desafio, implementaremos uma app de Delivery em equipe, dividindo tarefas e seguindo todas as boas práticos de desenvo

Globant iOS Academy Base Project
Globant iOS Academy Base Project

The repository will be used for trainees to save course progress.

libuv base Swift web HTTP server framework

Notice Trevi now open a Trevi Community. Yoseob/Trevi project split up into respective Trevi, lime, middlewares and sys packages at our community. If

Base view Ctl

YoViewCtl Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation YoViewCt

Owner
Thomas Durand
Software Architect & Code owner in Paris, I've a passion with iOS development and Swift programming language. I've also deep knowlegde in web app security
Thomas Durand
A fast, convenient and nonintrusive conversion framework between JSON and model. Your model class doesn't need to extend any base class. You don't need to modify any model file.

MJExtension A fast, convenient and nonintrusive conversion framework between JSON and model. 转换速度快、使用简单方便的字典转模型框架 ?? ✍??Release Notes: more details Co

M了个J 8.5k Jan 3, 2023
Random and time-ordered UUID generation in Swift

UniqueID UUIDv4 and v6* generation in Swift. [API Reference] A UUID is an identifier that is unique across both space and time, with respect to the sp

Karl 34 Nov 16, 2022
⛵️ URLNavigator provides an elegant way to navigate through view controllers by URLs.

URLNavigator ⛵️ URLNavigator provides an elegant way to navigate through view controllers by URLs. URL patterns can be mapped by using URLNavigator.re

Suyeol Jeon 2.6k May 27, 2021
A Swift client library for generating URLs with imgix

imgix-swift is a client library for generating image URLs with imgix. Written in Swift, but can be used with Objective-C codebases as well. Installati

imgix 24 Sep 28, 2022
DZURLRoute is an Objective-C implementation that supports standard-based URLs for local page jumps.

DZURLRoute Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements s.dependency 'DZVie

yishuiliunian 72 Aug 23, 2022
Makes building HTTP URLs and requests easy.

ModestProposal 2.0 Makes building HTTP URLs and requests easy. Can be used with any networking library that accepts NSURLRequest as a parameter. Featu

Justin Kolb 10 Jun 3, 2021
Link - a macos application for keeping important and complicated urls in one place

Link Description Link is a macos application for keeping important and complicat

Johan Solbakken 2 Jul 21, 2022
A swift package(SPM) with iOS UI component that loads and displays images from remote urls or local assets and displays in a slide-show form with auto scroll feature.

MDBannersView A swift package with an iOS UI component that loads and displays images from remote urls, local assets and displays in a slide-show form

Madhav Deva 2 Feb 5, 2022
Swift package that uses WebKit to render PDF files from URLs

Swift package for generating a PDF file from a URL (rendered by WebKit)

aaronland 1 Feb 25, 2022
Compile-time-checked URLs

SafeURL Tool for avoiding using the URL(string:) initializer with optional result, instead introducing a compile time URL validity check. Note, this d

Jhonatan A. 134 Dec 10, 2022