Skip to content

Commit f852131

Browse files
authored
Merge pull request #5429 from plotly/no-whitespace-in-compress-attrs
Leave no whitespace in compress_attributes when removing an attribute
2 parents 6191e66 + 1436b9c commit f852131

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tasks/compress_attributes.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,27 @@ var through = require('through2');
55
* of the plotly.js bundles
66
*/
77

8+
var WHITESPACE_BEFORE = '\\s*';
9+
var OPTIONAL_COMMA = ',?';
810

911
// one line string with or without trailing comma
1012
function makeStringRegex(attr) {
1113
return makeRegex(
12-
attr + ': \'.*\'' + ',?'
14+
WHITESPACE_BEFORE + attr + ': \'.*\'' + OPTIONAL_COMMA
1315
);
1416
}
1517

1618
// joined array of strings with or without trailing comma
1719
function makeJoinedArrayRegex(attr) {
1820
return makeRegex(
19-
attr + ': \\[[\\s\\S]*?\\]' + '\\.join\\(.*' + ',?'
21+
WHITESPACE_BEFORE + attr + ': \\[[\\s\\S]*?\\]' + '\\.join\\(.*' + OPTIONAL_COMMA
2022
);
2123
}
2224

2325
// array with or without trailing comma
2426
function makeArrayRegex(attr) {
2527
return makeRegex(
26-
attr + ': \\[[\\s\\S]*?\\]' + ',?'
28+
WHITESPACE_BEFORE + attr + ': \\[[\\s\\S]*?\\]' + OPTIONAL_COMMA
2729
);
2830
}
2931

0 commit comments

Comments
 (0)