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

truncate fails on plain text without HTML #23

@MortenHofft

Description

@MortenHofft

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions