Skip to content

Commit d335894

Browse files
committed
correctly flatten command with line continuation when copying
1 parent 32d1967 commit d335894

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/js/06-copy-to-clipboard.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444

4545
function extractCommands (text) {
4646
var cmdRx = /^\$ (\S[^\\\n]*(\\\n(?!\$ )[^\\\n]*)*)(?=\n|$)/gm
47-
var cleanupRx = /( )? *\\\n */g
47+
var cleanupRx = /( ) *\\\n *|\\\n( ?) */g
4848
var cmds = []
4949
var m
50-
while ((m = cmdRx.exec(text))) cmds.push(m[1].replace(cleanupRx, '$1'))
50+
while ((m = cmdRx.exec(text))) cmds.push(m[1].replace(cleanupRx, '$1$2'))
5151
return cmds.join(' && ')
5252
}
5353

0 commit comments

Comments
 (0)