Repository navigation
fix(split): split on any whitespace for a single space, like Ruby - #992
Merged
harttle merged 2 commits intoNov 21, 2026
Merged
Conversation
bardrop
reviewed
Nov 16, 2026
jayhemnani9910
force-pushed
the
fix/split-single-space-whitespace
branch
from
November 20, 2026 20:04
00411ff to
150b3ac
Compare
harttle
approved these changes
Nov 21, 2026
Owner
|
@all-contributors please add @jayhemnani9910 for code |
Contributor
|
I've put up a pull request to add @jayhemnani9910! 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
splitalready follows Ruby'sString#splitby dropping trailing empty strings, but Ruby treats a single-space separator specially: it splits on runs of any whitespace and ignores leading whitespace. liquidjs splits on the literal space, so tabs and newlines stay inside the items and repeated spaces give empty items:{{ " one two three " | split: " " | join: "|" }}Shopify Liquid gives
one|two|three; liquidjs gives||one||two\nthree. The common{{ content | split: " " | size }}word count is off for any text with double spaces or line breaks.With a single space as the separator,
splitnow trims the string and splits on/\s+/(an all-whitespace string gives an empty array, as in Ruby). Every other separator works as before.Tests: new case in
test/integration/filters/string.spec.ts, which fails without the change.npm run build && npx jest: 1751 passed. eslint is clean.