CocoaPods trunk is moving to be read-only. Read more on the blog, there are 13 months to go.
| TestsTested | ✓ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Jun 2016 |
| SPMSupports SPM | ✗ |
Maintained by Michał Tynior.
Returns information about Nancy style path strings such as /rebels/{name}/{action}/.
You can also manually add PathSlicer to you project:
Sources folder into you project’s tree.let slicer = PathSlicer()
let path = "/rebels/{name}/{action}"
let pathDescription = slicer.getPathDescription(path)The pathDescription variable contains following values:
pathDescription = {
regex = "rebels\\/([^\\\\/]+?)\\/([^\\\\/]+?)(?:\\/(?=$))?$",
arguments = [ "name", "action" ]
}Literal segments don’t contain any arguments and are matched as they are.
let slicer = PathSlicer()
let path = "/empire/darth_vader/choke"
let pathDescription = slicer.getPathDescription(path)The pathDescription variable contains following values:
pathDescription = {
regex = "/empire/darth_vader/choke(?:\\/(?=$))?$",
arguments = [ ]
}Capture segments allow to add parameters to the paths. Each capture segment is surrounded by { and }. Capture segments are returned in argument property of path description.
let slicer = PathSlicer()
let path = "/empire/{name}/{action}"
let pathDescription = slicer.getPathDescription(path)The pathDescription variable contains following values:
pathDescription = {
regex = "empire\\/([^\\\\/]+?)\\/([^\\\\/]+?)(?:\\/(?=$))?$",
arguments = [ "name", "action" ]
}RegEx segments allows to define custom component machers. Right now named caupture groups of regular expression are not returned as arguments of path description.
let slicer = PathSlicer()
let path = "/can_be_jedi/(?<age>[\\d]{1,2})"
let pathDescription = slicer.getPathDescription(path)The pathDescription variable contains following values:
pathDescription = {
regex = "can_be_jedi/(?<age>[\\d]{1,2})(?:\\/(?=$))?$",
arguments = [ ]
}PathSlicer is released under the MIT license. See LICENSE for details.