Update lib/liquid/standardfilters.rb

Co-authored-by: Dylan Thacker-Smith <dylan.smith@shopify.com>
This commit is contained in:
Aaron Patterson
2020-11-16 10:23:20 -08:00
committed by GitHub
parent 8bf0e7dfae
commit 94df9a8f52

View File

@@ -91,12 +91,11 @@ module Liquid
return if input.nil?
words = Utils.to_integer(words)
l = words
l = 1 if l <= 0
words = 1 if words <= 0
# Scan for non-space characters followed by one or more space characters
# `l` times. Also ignore leading whitespace
str = input[/\A[ ]*(?:[^ ]*[ ]+){#{l}}/]
# `words` times. Also ignore leading whitespace
str = input[/\A[ ]*(?:[^ ]*[ ]+){#{words}}/]
if str
str.strip! # Remove trailing space