Skip to content

Commit

Permalink
fix: escape sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryu0118 committed Sep 12, 2022
1 parent 4e960a9 commit 80c911a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
22 changes: 22 additions & 0 deletions Sources/MagicIBCore/Extensions/String+escapeSequence.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// String+escapeSequence.swift
//
//
// Created by Ryu on 2022/09/13.
//

import Foundation

extension String {
func escapingSequence() -> String {
self.map {
if $0 == "\"" {
return "\\" + "\($0)"
}
else {
return "\($0)"
}
}
.joined()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension IBPropertyMapper {
return ".\(value)"
case .string:
guard let value = value as? String else { return nil }
return "\"\(value)\""
return "\"\(value.escapingSequence())\""
default:
guard let nonCustomizable = value as? NonCustomizable else { return nil }
return nonCustomizable.getRightOperand()
Expand Down
2 changes: 1 addition & 1 deletion Sources/MagicIBCore/IBFunctionMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class IBFunctionMapper {
return ".\(value)"
case .string:
guard let value = value as? String else { return nil }
return "\"\(value)\""
return "\"\(value.escapingSequence())\""
default:
guard let nonCustomizable = value as? NonCustomizable else { return nil }
return nonCustomizable.getRightOperand()
Expand Down

0 comments on commit 80c911a

Please sign in to comment.