Closed GriffinHeart closed 9 years ago
input = 'feafawefaefawfafeafafeafeeaefa feawfaweffeawfeafeafaefafeafafaeafeafeafaefafeafaefaefa <span class="wurl"><a href="http://google.com" target="_blank" rel="nofollow">http://google.com</a></span>'; actual = truncate(input, 100); expect = 'feafawefaefawfafeafafeafeeaefa feawfaweffeawfeafeafaefafeafafaeafeafeafaefafeafaefaefa <span class="wurl"><a href="http://google.com" target="_blank" rel="nofollow">http://google...</a></span>'; assert.strictEqual(actual, expect);
is this a bug?
here is a more simple version:
input = 'thisare19characters <a href="http://google.com">http://google.com</a>'; actual = truncate(input, 33); expect = 'thisare19characters <a href="http://google.com">http://google...</a>'; assert.strictEqual(actual, expect);
I think the problem comes from here https://github.com/huang47/nodejs-html-truncate/blob/master/truncate.js#L166 :
After breaking from the loop string is the remaining content of the string which doesn't make sense to compare for maxLength. shouldn't this be: total > maxLength?
string
maxLength
total > maxLength
I am seeing this as well
Opened #10 to resolve
is this a bug?
here is a more simple version:
I think the problem comes from here https://github.com/huang47/nodejs-html-truncate/blob/master/truncate.js#L166 :
After breaking from the loop
string
is the remaining content of the string which doesn't make sense to compare formaxLength
. shouldn't this be:total > maxLength
?