microlinkhq / metascraper

Get unified metadata from websites using Open Graph, Microdata, RDFa, Twitter Cards, JSON-LD, HTML, and more.
https://metascraper.js.org
MIT License
2.35k stars 168 forks source link

Remove duplicate truncate dependency #449

Closed mac-chaffee closed 3 years ago

mac-chaffee commented 3 years ago

metadata-helpers relies on https://www.npmjs.com/package/truncate, but that utility is already provided by lodash: https://lodash.com/docs/4.17.15#truncate

Additionally, node-truncate has an extra behavior where it won't truncate URLs no matter how long they are, which users likely don't expect: https://github.com/FGRibreau/node-truncate/blob/a92d6b66f5a71c33e52484862ed069fa12411b24/truncate.js#L12

There is a very slight difference with lodash's truncate: it will replace the last character with "…" rather than appending it, so I had to update the test, but I don't anticipate too many people are relying on that behavior ;)

Kikobeats commented 3 years ago

I originally added truncate to keep URLs there but it's true an URL can be so long, so let's merge the PR 🙂