@@ -156,9 +156,10 @@ export const toMap = (config: Properties): Map<string, string> => {
156
156
* @param key Key, can be empty string.
157
157
* @param value Value, can be empty string.
158
158
* @param sep Separator, cannot be empty. Valid chars are ` :=`.
159
+ * @param escapeUnicode Enable/disable unicode escaping.
159
160
*/
160
- const formatLine = ( key : string , value : string , sep : string ) =>
161
- `${ escapeKey ( key ) } ${ sep } ${ escapeValue ( value ) } `
161
+ const formatLine = ( key : string , value : string , sep : string , escapeUnicode : boolean ) =>
162
+ `${ escapeKey ( key , escapeUnicode ) } ${ sep } ${ escapeValue ( value , escapeUnicode ) } `
162
163
163
164
/**
164
165
* Set or remove value for the given key.
@@ -174,19 +175,20 @@ export const set = (
174
175
value : string | undefined | null ,
175
176
options ?: { separator ?: string }
176
177
) : void => {
177
- let sep = '='
178
+ const escapeUnicode = true
179
+ let lastSep = '='
178
180
let found = false
179
181
180
182
// Find all entries
181
183
for ( const entry of listPairs ( config . lines ) ) {
182
184
// Remember separator
183
- if ( entry . sep ) sep = entry . sep
185
+ if ( entry . sep ) lastSep = entry . sep
184
186
185
187
// If found, either replace or remove
186
188
if ( key === entry . key ) {
187
189
const items =
188
190
! found && typeof value === 'string'
189
- ? [ formatLine ( key , value , options ?. separator || sep ) ]
191
+ ? [ formatLine ( key , value , options ?. separator || lastSep , escapeUnicode ) ]
190
192
: [ ]
191
193
192
194
config . lines . splice ( entry . start , entry . len , ...items )
@@ -196,7 +198,7 @@ export const set = (
196
198
197
199
// Not found, append
198
200
if ( ! found && typeof value === 'string' ) {
199
- config . lines . push ( formatLine ( key , value , options ?. separator || sep ) )
201
+ config . lines . push ( formatLine ( key , value , options ?. separator || lastSep , escapeUnicode ) )
200
202
}
201
203
}
202
204
0 commit comments