File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,14 @@ protocol YAMLRepresentable {
15
15
extension String : YAMLRepresentable {
16
16
var YAML : String {
17
17
if self == " " { return " \" \" " }
18
+ for c in utf8 {
19
+ switch c {
20
+ case UInt8 ( ascii: " @ " ) , UInt8 ( ascii: " " ) , UInt8 ( ascii: " - " ) , UInt8 ( ascii: " & " ) :
21
+ return " \" \( self ) \" "
22
+ default :
23
+ continue
24
+ }
25
+ }
18
26
return self
19
27
}
20
28
}
@@ -28,15 +36,6 @@ extension Bool: YAMLRepresentable {
28
36
29
37
extension Array where Element: YAMLRepresentable {
30
38
var YAML : String {
31
- func quote( _ input: String ) -> String {
32
- for c in input. characters {
33
- if c == " @ " || c == " " || c == " - " || c == " & " {
34
- return " \" \( input) \" "
35
- }
36
- }
37
- return input
38
- }
39
- let stringArray = self . flatMap { String ( $0) }
40
- return " [ " + stringArray. map ( quote) . joined ( separator: " , " ) + " ] "
39
+ return " [ " + map{ $0. YAML} . joined ( separator: " , " ) + " ] "
41
40
}
42
41
}
You can’t perform that action at this time.
0 commit comments