Our storefront templates use strip, lstrip and rstrip with an argument to remove decorative characters from product badges, for example {{ badge | strip: "🎉" }}. With ordinary characters this works. When the characters…
Our storefront templates use strip, lstrip and rstrip with an argument to remove decorative characters from product badges, for example {{ badge | strip: "🎉" }}. With ordinary characters this works. When the characters to remove are emoji, or some less common CJK characters such as 𠮷, the filters return the text unchanged.
{{ "🎉🎉Sale🎉" | strip: "🎉" }}.{{ input | lstrip: chars }} with input set to 🙂🙂hi🙂 and chars set to 🙂.{{ "a𠮷text𠮷a" | strip: "a𠮷" }}.Salehi🙂text🎉🎉Sale🎉🙂🙂hi🙂𠮷text𠮷 (the a is removed, the 𠮷 is not){{ "--hello--" | strip: "-" }} gives hello, and accented letters such as é are trimmed correctly too, so most of our templates never hit this.𠮶 is a different character from 𠮷 and must stay when only 𠮷 is listed. An emoji in the middle of the text stays where it is.Adapted from harttle/liquidjs (MIT).
Visible test command
TZ=UTC npx --no-install jest --ci --coverage=falseThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
strip-filters-ignore-emoji
Changes under src/ are evaluated.