Closed aaren-cordova closed 7 years ago
This regex leaves a single empty space/tab at beginning and the end. Is that the behavior we want ?
IIRC, we want to leave a space at the end only so that Hello world,
retains its trailing space.
Some "failing" examples
const regex = /\s{2,}/g
`\nBlow your mind\n`.replace(regex, ' '); // leaves new line at beginning/end
`\nBlow\n your\n mind\n`.replace(regex, ''); // Blowyourmind => removes new lines and spaces
`\t Blow\t your mind`.replace(regex, ''); // Blowyourmind => removes all spaces
` \t Blow your mind \t`.replace(regex, ''); // doesn't leave space at the beginning and end
I think they should all give the same output
Awesome, I was relying solely on the tests to define the bounds of what is proper input and output text. I'll update it to include the failing examples @nightwolfz mentioned.
Getting a few tests failing, but I'm not quite sure they line up with the above comment.
Tests like:
<div class="tab-group">inlineText\t</div>
to equal <div class="tab-group">inlineText</div>
The above changes should now convert it to:
<div class="tab-group">inline \t\t \rtext \n \r \t</div>
to equal <div class="tab-group">inline\rtext\t</div>
So I may need update a few of the tests in inferno before I can move this one on through.
I've added a fix (taken from the Mithril MSX plugin) that seems to work. Even if it is very long winded and much slower – it seems to work in all the test cases.
@nightwolfz please can your code review too?