Skip to content

Conversation

@rosomri
Copy link
Contributor

@rosomri rosomri commented Oct 26, 2025

Summary

This PR adds two standard Shopify filters (base64_encode and base64_decode) to LiquidJS core to improve Shopify compatibility. These filters are part of the standard Shopify Liquid filter set but were not previously implemented in LiquidJS.

#827

Changes

  • New Filters: Added base64_encode and base64_decode filters with full Shopify compatibility
  • Platform-specific Implementation:
    • Node.js: Uses Buffer.from() for optimal performance
    • Browser: Uses btoa/atob with proper Unicode handling
  • Rollup Integration: Added bundle options to replace implementations during build
  • Comprehensive Testing: Added tests for both Node.js and browser implementations
  • Memory Management: Integrated with LiquidJS's memory limit system

Implementation Details

  • src/filters/base64.ts - Main filter implementation
  • src/filters/base64-impl.ts - Node.js implementation using Buffer
  • src/build/base64-impl-browser.ts - Browser implementation using btoa/atob
  • test/integration/filters/base64.spec.ts - Integration tests
  • src/build/base64-impl-browser.spec.ts - Browser-specific unit tests
  • Updated rollup.config.mjs with platform-specific bundling

Shopify Compatibility

  • ✅ Matches Shopify's exact output for {{ 'one two three' | base64_encode }}b25lIHR3byB0aHJlZQ==
  • ✅ Handles Unicode characters correctly
  • ✅ Supports all input types (strings, numbers, booleans)
  • ✅ Proper error handling for edge cases

Testing

  • unit tests for browser implementation
  • integration tests covering all scenarios
  • Round-trip encoding/decoding verification
  • Unicode and special character handling
  • Cross-platform compatibility verified

Breaking Changes

None

@coveralls
Copy link

coveralls commented Oct 26, 2025

Pull Request Test Coverage Report for Build 18834524874

Details

  • 20 of 20 (100.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 99.875%

Totals Coverage Status
Change from base Build 18814456173: 0.0%
Covered Lines: 2906
Relevant Lines: 2908

💛 - Coveralls

@rosomri rosomri requested a review from harttle October 27, 2025 08:27
@harttle
Copy link
Owner

harttle commented Oct 27, 2025

atob doesn’t work for non alphabetic characters. Let’s stick with your original solution.
I saw TextEncoder is available for major browsers 5 years ago. Maybe just I am too old.

@harttle
Copy link
Owner

harttle commented Oct 27, 2025

@rosomri thanks for the effort!

@rosomri
Copy link
Contributor Author

rosomri commented Oct 27, 2025

@harttle happy to contribute whenever needed!
All comments have been addressed, let me know if there’s anything else you’d like me to update.

@harttle harttle merged commit 86fc135 into harttle:master Oct 27, 2025
13 checks passed
@harttle
Copy link
Owner

harttle commented Oct 27, 2025

@all-contributors please add @rosomri for code

@allcontributors
Copy link
Contributor

@harttle

I've put up a pull request to add @rosomri! 🎉

github-actions bot pushed a commit that referenced this pull request Oct 27, 2025
# [10.24.0](v10.23.0...v10.24.0) (2025-10-27)

### Features

* **filters:** Add base64_encode and base64_decode filters for Shopify compatibility ([#828](#828)) ([86fc135](86fc135))
@github-actions
Copy link

🎉 This PR is included in version 10.24.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

rosomri added a commit to elastic/kibana that referenced this pull request Oct 28, 2025
…JS implementation (#240862)

### PR Description
We previously implemented custom base64 filters as a workaround when
LiquidJS didn't have native base64 support. After [contributing these
filters to the LiquidJS open source
project](harttle/liquidjs#828), they are now
available natively in v10.24.0, making our custom implementation
redundant.

### Changes
- Updated LiquidJS dependency from v10.22.0 to v10.24.0
- Removed custom base64 filters and related tests

---------

Co-authored-by: kibanamachine <[email protected]>
qn895 pushed a commit to qn895/kibana that referenced this pull request Oct 30, 2025
…JS implementation (elastic#240862)

### PR Description
We previously implemented custom base64 filters as a workaround when
LiquidJS didn't have native base64 support. After [contributing these
filters to the LiquidJS open source
project](harttle/liquidjs#828), they are now
available natively in v10.24.0, making our custom implementation
redundant.

### Changes
- Updated LiquidJS dependency from v10.22.0 to v10.24.0
- Removed custom base64 filters and related tests

---------

Co-authored-by: kibanamachine <[email protected]>
ana-davydova pushed a commit to ana-davydova/kibana that referenced this pull request Nov 3, 2025
…JS implementation (elastic#240862)

### PR Description
We previously implemented custom base64 filters as a workaround when
LiquidJS didn't have native base64 support. After [contributing these
filters to the LiquidJS open source
project](harttle/liquidjs#828), they are now
available natively in v10.24.0, making our custom implementation
redundant.

### Changes
- Updated LiquidJS dependency from v10.22.0 to v10.24.0
- Removed custom base64 filters and related tests

---------

Co-authored-by: kibanamachine <[email protected]>
albertoblaz pushed a commit to albertoblaz/kibana that referenced this pull request Nov 4, 2025
…JS implementation (elastic#240862)

### PR Description
We previously implemented custom base64 filters as a workaround when
LiquidJS didn't have native base64 support. After [contributing these
filters to the LiquidJS open source
project](harttle/liquidjs#828), they are now
available natively in v10.24.0, making our custom implementation
redundant.

### Changes
- Updated LiquidJS dependency from v10.22.0 to v10.24.0
- Removed custom base64 filters and related tests

---------

Co-authored-by: kibanamachine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants