神刀安全网

[iOS] URITemplate.swift:方便实用的 URI 模式匹配库

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 thetest 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. SeeLICENSE for more info.

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » [iOS] URITemplate.swift:方便实用的 URI 模式匹配库

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址