Skip to content

Commit

Permalink
Add pathComponents property to the String (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
emarashliev authored Feb 27, 2020
1 parent 6a8a163 commit 9eccd81
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/RoutingKit/PathComponent.swift
Original file line number Diff line number Diff line change
@@ -54,6 +54,13 @@ public enum PathComponent: ExpressibleByStringLiteral, CustomStringConvertible {
}
}

extension String {
/// Converts a string into `[PathComponent]`.
public var pathComponents: [PathComponent] {
return self.split(separator: "/").map { .init(stringLiteral: .init($0)) }
}
}

extension Array where Element == PathComponent {
/// Converts an array of `PathComponent` into a readable path string.
///

0 comments on commit 9eccd81

Please sign in to comment.