@@ -19,7 +19,7 @@ struct FormatError: Error {
19
19
}
20
20
21
21
extension TypedVariableValue {
22
- func formatForTemplateExpansion( variableSpec: VariableSpec , expansionConfiguration configuration: ExpansionConfiguration ) throws -> String ? {
22
+ func formatForTemplateExpansion( variableSpec: VariableSpec , expansionConfiguration configuration: ExpansionConfiguration ) throws ( FormatError ) -> String ? {
23
23
switch self {
24
24
case let . string( plainValue) :
25
25
return try plainValue. formatForTemplateExpansion ( variableSpec: variableSpec, expansionConfiguration: configuration)
@@ -45,7 +45,7 @@ extension TypedVariableValue {
45
45
}
46
46
}
47
47
48
- private func percentEncode( string: String , withAllowedCharacters allowedCharacterSet: CharacterSet , allowPercentEncodedTriplets: Bool ) throws -> String {
48
+ private func percentEncode( string: String , withAllowedCharacters allowedCharacterSet: CharacterSet , allowPercentEncodedTriplets: Bool ) throws ( FormatError ) -> String {
49
49
guard var encoded = string. addingPercentEncoding ( withAllowedCharacters: allowedCharacterSet) else {
50
50
throw FormatError ( reason: " Percent Encoding Failed " )
51
51
}
@@ -73,7 +73,7 @@ private func percentEncode(string: String, withAllowedCharacters allowedCharacte
73
73
}
74
74
75
75
private extension StringProtocol {
76
- func formatForTemplateExpansion( variableSpec: VariableSpec , expansionConfiguration: ExpansionConfiguration ) throws -> String {
76
+ func formatForTemplateExpansion( variableSpec: VariableSpec , expansionConfiguration: ExpansionConfiguration ) throws ( FormatError ) -> String {
77
77
let modifiedValue = if let prefixLength = variableSpec. prefixLength ( ) {
78
78
String ( prefix ( prefixLength) )
79
79
} else {
@@ -91,9 +91,9 @@ private extension StringProtocol {
91
91
}
92
92
93
93
private extension Array where Element: StringProtocol {
94
- func formatForTemplateExpansion( variableSpec: VariableSpec , expansionConfiguration: ExpansionConfiguration ) throws -> String ? {
94
+ func formatForTemplateExpansion( variableSpec: VariableSpec , expansionConfiguration: ExpansionConfiguration ) throws ( FormatError ) -> String ? {
95
95
let separator = " , "
96
- let encodedExpansions = try map { element -> String in
96
+ let encodedExpansions = try map { element throws ( FormatError ) -> String in
97
97
return try percentEncode ( string: String ( element) , withAllowedCharacters: expansionConfiguration. percentEncodingAllowedCharacterSet, allowPercentEncodedTriplets: expansionConfiguration. allowPercentEncodedTriplets)
98
98
}
99
99
if encodedExpansions. count == 0 {
@@ -109,9 +109,9 @@ private extension Array where Element: StringProtocol {
109
109
return expansion
110
110
}
111
111
112
- func explodeForTemplateExpansion( variableSpec: VariableSpec , expansionConfiguration: ExpansionConfiguration ) throws -> String ? {
112
+ func explodeForTemplateExpansion( variableSpec: VariableSpec , expansionConfiguration: ExpansionConfiguration ) throws ( FormatError ) -> String ? {
113
113
let separator = expansionConfiguration. separator
114
- let encodedExpansions = try map { element -> String in
114
+ let encodedExpansions = try map { element throws ( FormatError ) -> String in
115
115
let encodedElement = try percentEncode ( string: String ( element) , withAllowedCharacters: expansionConfiguration. percentEncodingAllowedCharacterSet, allowPercentEncodedTriplets: expansionConfiguration. allowPercentEncodedTriplets)
116
116
if expansionConfiguration. named {
117
117
if encodedElement. isEmpty && expansionConfiguration. omitOrphanedEquals {
@@ -129,8 +129,8 @@ private extension Array where Element: StringProtocol {
129
129
}
130
130
131
131
private extension [ ( key: String , value: String ) ] {
132
- func formatForTemplateExpansion( variableSpec: VariableSpec , expansionConfiguration: ExpansionConfiguration ) throws -> String ? {
133
- let encodedExpansions = try map { key, value -> String in
132
+ func formatForTemplateExpansion( variableSpec: VariableSpec , expansionConfiguration: ExpansionConfiguration ) throws ( FormatError ) -> String ? {
133
+ let encodedExpansions = try map { key, value throws ( FormatError ) -> String in
134
134
let encodedKey = try percentEncode ( string: String ( key) , withAllowedCharacters: expansionConfiguration. percentEncodingAllowedCharacterSet, allowPercentEncodedTriplets: expansionConfiguration. allowPercentEncodedTriplets)
135
135
let encodedValue = try percentEncode ( string: String ( value) , withAllowedCharacters: expansionConfiguration. percentEncodingAllowedCharacterSet, allowPercentEncodedTriplets: expansionConfiguration. allowPercentEncodedTriplets)
136
136
return " \( encodedKey) , \( encodedValue) "
@@ -145,9 +145,9 @@ private extension [(key: String, value: String)] {
145
145
return expansion
146
146
}
147
147
148
- func explodeForTemplateExpansion( variableSpec: VariableSpec , expansionConfiguration: ExpansionConfiguration ) throws -> String ? {
148
+ func explodeForTemplateExpansion( variableSpec: VariableSpec , expansionConfiguration: ExpansionConfiguration ) throws ( FormatError ) -> String ? {
149
149
let separator = expansionConfiguration. separator
150
- let encodedExpansions = try map { key, value -> String in
150
+ let encodedExpansions = try map { key, value throws ( FormatError ) -> String in
151
151
let encodedKey = try percentEncode ( string: String ( key) , withAllowedCharacters: expansionConfiguration. percentEncodingAllowedCharacterSet, allowPercentEncodedTriplets: expansionConfiguration. allowPercentEncodedTriplets)
152
152
let encodedValue = try percentEncode ( string: String ( value) , withAllowedCharacters: expansionConfiguration. percentEncodingAllowedCharacterSet, allowPercentEncodedTriplets: expansionConfiguration. allowPercentEncodedTriplets)
153
153
if expansionConfiguration. named && encodedValue. isEmpty && expansionConfiguration. omitOrphanedEquals {
0 commit comments