Swiftpack.co - kylef/URITemplate.swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
kylef/URITemplate.swift
Swift implementation of URI Template (RFC6570)
.package(url: "https://github.com/kylef/URITemplate.swift.git", from: "3.0.1")

URITemplate

Swift implementation of URI Template (RFC6570).

Installation

CocoaPods is the recommended installation method.

pod 'URITemplate'

Example

Expanding a URI Template

let template = URITemplate(template: "https://api.github.com/repos/{owner}/{repo}/")
let url = template.expand(["owner": "kylef", "repo": "URITemplate.swift"])
=> "https://api.github.com/repos/kylef/URITemplate.swift/"

Determine which variables are in a template

let variables = template.variables
=> ["owner", "repo"]

Extract the variables used in a given URL

let variables = template.extract("https://api.github.com/repos/kylef/PathKit/")
=> ["owner":"kylef", "repo":"PathKit"]

RFC6570

The URITemplate library follows the test suite.

We have full support for level 4 of RFC6570 when expanding a template and retrieving the variables in a template.

For extraction of variables from an already expanded template, level 3 is supported.

License

URITemplate is licensed under the MIT license. See LICENSE for more info.

GitHub

link
Stars: 191
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

3.0.0
2 years ago

Breaking

  • Support for Swift < 4.2 has been removed.

Enhancements

  • Adds support for Swift 5.0.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics