/// 引数からURLを作成して返却する
///
/// - Parameters:
/// - path: パス文字列
/// - args: パラメーター(Dictionary)
/// - Returns: URL
public func url(_ path: String, args: Dictionary<String, String>? = nil) -> URL {
func joinPath(_ k: String...) -> URL {
return URL(string: ([baseUrl] + k).joined(separator: ""))!
}
if let args = args {
return joinPath(path + "?" + args.map({
"\($0.0.urlEscapedString)=\($0.1.urlEscapedString)"
}).joined(separator: "&"))
} else {
return joinPath(path)
}
}
Last active
January 6, 2018 23:34
-
-
Save KentarouKanno/a842c4a87359815c28b3164a42b56ea1 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment