imcvampire / vue-truncate-filter

A filter for Vuejs to truncate string
MIT License
57 stars 6 forks source link

Truncate a bit too aggressive #3

Closed koriroys closed 7 years ago

koriroys commented 7 years ago

If for example I have a title that has no spaces in it, aka var title = 'MY_SUPER_AMAZING_TITLE', and I call truncate like so:

{{title | truncate(15, '...')}} my output is just '...'

I added

if (last === 0)
  last = length - clamp.length

basically if it gets to the start and didn't find any spaces, just default back to the full string and cut it at the max.

I think this should be the standard behavior (I expect that if there is some title at all, it will show something, not just '...'). What do you think?

imcvampire commented 7 years ago

Thanks for your idea. I will dig into it ASAP.

And you're welcome to contribute a PR to make this package better :)

imcvampire commented 7 years ago

Fixed https://github.com/imcvampire/vue-truncate-filter/releases/tag/1.1.6