jprichardson / string.js

Extra JavaScript string methods.
http://stringjs.com
1.81k stars 234 forks source link

S('foo<br>bar').stripTags() == 'foobar' #228

Open HxxxxxS opened 5 years ago

HxxxxxS commented 5 years ago

IMO should be 'foo bar', no? More relevant use case:

let body = 'Hello {name}!<br>Please verify your email at url <a href="https://example.com/verify/12345">https://example.com/verify/1234</a><br>See you soon'
let text = S(body).stripTags().s
// Hello {name}!Please verify your email at url https://example.com/verify/12345See you soon
//              ^                                                               ^
siddharthborderwala commented 4 years ago

The stripTags method is meant to remove the tags only and not alter the string in any other way. So, the tags will be replaced by no white space.