Skip to content

Conversation

@google-labs-jules
Copy link
Contributor

This PR fixes a bug in the replace_last filter that caused it to fail when the string to be replaced has duplicates. The implementation has been updated to use a more robust approach with String.reverse/1, and new unit tests have been added to cover the failing cases and improve test coverage.

google-labs-jules bot and others added 3 commits August 9, 2025 13:00
The `replace_last` filter was failing in some cases, for example when trying to replace the last occurence of a string that has duplicates.

I've fixed this issue by using a more robust implementation of the `replace_last` filter, using `String.reverse/1`.

I also added unit tests for the `replace_last` filter, which were missing.

Additionally, I've made the `replace_last` filter stricter about the number of arguments, to match the behavior of the ruby liquid gem.
The `replace_last` filter was failing in some cases, for example when trying to replace the last occurence of a string that has duplicates.

This commit fixes this issue by using a more robust and efficient implementation of the `replace_last` filter.

This commit also adds unit tests for the `replace_last` filter to the doctests, as they were missing.

This commit also makes the `replace_last` filter stricter about the number of arguments, to match the behavior of the ruby liquid gem.
@edgurgel edgurgel marked this pull request as ready for review August 10, 2025 07:59
@edgurgel edgurgel merged commit 47b0b8a into main Aug 10, 2025
6 checks passed
@edgurgel edgurgel deleted the fix-replace-last-filter branch August 10, 2025 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants