Closed mattiaerre closed 4 years ago
Prune doesn't allow having non-word characters (like punctuation characters) after the last word. This increases the readability of the truncated phrase.
For example, this is better in sense of truncation:
v.prune('Good day. Little Red Riding Hood', 16, '...');
// => 'Good day...'
Compared to:
v.prune('Good day. Little Red Riding Hood', 16, '...');
// => 'Good day. ...'
thanks @panzerdp for the quick answer, really appreciated; my point is that this is not always the case as this is what's happening now:
expect(v.prune('YATTA,', 6, '')).toEqual('YATTA,');
expect(v.prune('YATTA, ', 6, '')).toEqual('YATTA');
the 1st string w/o a final empty space returns the comma, the second one w/ space doesn't; using your example:
expect(v.prune('Good day. Little Red Riding Hood,', 12, '')).toEqual(
'Good day'
);
expect(v.prune('Good day. Little Red Riding Hood,', 33, '')).toEqual(
'Good day. Little Red Riding Hood,'
);
the 1st string does not return the punctuation. thanks again, -Mattia
Prune is applied (including the removal of non-word chars) only when the string length is bigger than prune length. Otherwise the string is not modified, because there's nothing to remove.
oh I see @panzerdp although I still think that
v.prune('YATTA, ', 6, '')
should return
YATTA,
w/ the comma
and not
YATTA
Welcome to Voca's GitHub repo!
Expected behavior :smile_cat:
Actual behavior :crying_cat_face:
Steps to reproduce :construction_worker:
https://github.com/mattiaerre/china-musk/blob/master/src/store/prune.test.js
Technical details: :wrench:
Browser/OS type: macOS Mojave Node version: v10
thanks so much, -Mattia