Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

truncate fails on plain text without HTML #23

Open
MortenHofft opened this issue Jan 12, 2017 · 0 comments
Open

truncate fails on plain text without HTML #23

MortenHofft opened this issue Jan 12, 2017 · 0 comments

Comments

@MortenHofft
Copy link

Thank you for a nice library. I've stumbled upon a bug the other day.

I cannot figure out exactly when this happens, but I have an example: https://runkit.com/hofft/5877633764cddc00146690a8

var truncate = require("html-truncate");
var str = 'abc (http://doi.org/10.3897/zookeys.555.6173) The dataset contains close to 2.5 million occurrences, recorded by 101 GPS trackers mounted on 75 Lesser Black-backed Gulls and 26 Herring Gulls breeding at the Belgian and Dutch coast (see https://inbo.cartodb.com/u/lifewatch/viz/da04f120-ea70-11e4-a3f2-0e853d047bba/public_map for a visualization of the data). (UvA-BiTS, http://www.uva-bits.nl). ';

//not being html I would expect it to have length ~3
console.log(truncate(str, 3)); 

/not being html I would expect it to have length ~13
console.log(truncate(str, 13)); 

result

"abc..."
and
"abc (http://doi.org/10.3897/zookeys.555.6173) The dataset contains close to 2.5 million occurrences, recorded by 101 GPS trackers mounted on 75 Lesser Black-backed Gulls and 26 Herring Gulls breeding at the Belgian and Dutch coast (see https://inbo.cartodb.com/u/lifewatch/viz/da04f120-ea70-11e4-a3f2-0e853d047bba/public_map..."

basically it seems that having multiple urls in the text breaks the truncating.

Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant