@@ -246,15 +246,15 @@ def substitute(ary, from, to)
246
246
res
247
247
end
248
248
249
- # Destructively strips whitespace from the beginning and end
250
- # of the first and last elements, respectively,
251
- # in the array (if those elements are strings) .
249
+ # Destructively strips whitespace from the beginning and end of the first
250
+ # and last elements, respectively, in the array (if those elements are
251
+ # strings). Preserves CSS escapes at the end of the array .
252
252
#
253
253
# @param arr [Array]
254
254
# @return [Array] `arr`
255
255
def strip_string_array ( arr )
256
256
arr . first . lstrip! if arr . first . is_a? ( String )
257
- arr . last . rstrip! if arr . last . is_a? ( String )
257
+ arr [ - 1 ] = Sass :: Util . rstrip_except_escapes ( arr [ - 1 ] ) if arr . last . is_a? ( String )
258
258
arr
259
259
end
260
260
@@ -289,6 +289,24 @@ def escaped_char(escape)
289
289
end
290
290
end
291
291
292
+ # Like [String#strip], but preserves escaped whitespace at the end of the
293
+ # string.
294
+ #
295
+ # @param string [String]
296
+ # @return [String]
297
+ def strip_except_escapes ( string )
298
+ rstrip_except_escapes ( string . lstrip )
299
+ end
300
+
301
+ # Like [String#rstrip], but preserves escaped whitespace at the end of the
302
+ # string.
303
+ #
304
+ # @param string [String]
305
+ # @return [String]
306
+ def rstrip_except_escapes ( string )
307
+ string . sub ( /(?<!\\ )\s +$/ , '' )
308
+ end
309
+
292
310
# Return an array of all possible paths through the given arrays.
293
311
#
294
312
# @param arrs [Array<Array>]
0 commit comments