mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 04:10:40 -07:00
Ruby/Shopify `slice` returns nil (rendered as an empty string or array) when
the begin offset falls outside the negative range or when the length is
negative. liquidjs forwarded the adjusted indices straight to
Array/String.prototype.slice, whose own negative-index handling produced
non-empty, incorrect output:
{{ "hello" | slice: -10, 2 }} => "he" (expected "")
{{ "Liquid" | slice: 1, -2 }} => "iqui" (expected "")
Guard the adjusted begin and the length before slicing.