diff options
| author | William Boman <william@redwill.se> | 2023-04-22 23:28:10 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-22 21:28:10 +0000 |
| commit | d76949e3b92a8a184bac683227c1024920fe763b (patch) | |
| tree | ba0fe13d72a7a66832d0fadb96b9d3c1ee051033 | |
| parent | refactor(schemas): don't vendor schemas in mason.nvim (#1248) (diff) | |
| download | mason-d76949e3b92a8a184bac683227c1024920fe763b.tar mason-d76949e3b92a8a184bac683227c1024920fe763b.tar.gz mason-d76949e3b92a8a184bac683227c1024920fe763b.tar.bz2 mason-d76949e3b92a8a184bac683227c1024920fe763b.tar.lz mason-d76949e3b92a8a184bac683227c1024920fe763b.tar.xz mason-d76949e3b92a8a184bac683227c1024920fe763b.tar.zst mason-d76949e3b92a8a184bac683227c1024920fe763b.zip | |
fix(expr): fix strip_{prefix,suffix} (#1249)
| -rw-r--r-- | lua/mason-core/installer/registry/expr.lua | 4 | ||||
| -rw-r--r-- | tests/mason-core/installer/registry/expr_spec.lua | 20 |
2 files changed, 22 insertions, 2 deletions
diff --git a/lua/mason-core/installer/registry/expr.lua b/lua/mason-core/installer/registry/expr.lua index 2bb3a149..ad7cfd43 100644 --- a/lua/mason-core/installer/registry/expr.lua +++ b/lua/mason-core/installer/registry/expr.lua @@ -34,8 +34,8 @@ end, 2) local FILTERS = { equals = _.equals, not_equals = _.not_equals, - strip_prefix = _.trim_start_matches, - strip_suffix = _.trim_end_matches, + strip_prefix = _.strip_prefix, + strip_suffix = _.strip_suffix, take_if = take_if, take_if_not = take_if_not, to_lower = _.to_lower, diff --git a/tests/mason-core/installer/registry/expr_spec.lua b/tests/mason-core/installer/registry/expr_spec.lua index 93efa6d4..65994dfa 100644 --- a/tests/mason-core/installer/registry/expr_spec.lua +++ b/tests/mason-core/installer/registry/expr_spec.lua @@ -216,6 +216,26 @@ describe("expr filters :: take_if{_not}", function() end) end) +describe("expr filters :: strip_{suffix,prefix}", function() + it("should strip prefix", function() + assert.same( + Result.success "1.0.0", + expr.interpolate([[{{value | strip_prefix("v") }}]], { + value = "v1.0.0", + }) + ) + end) + + it("should strip suffix", function() + assert.same( + Result.success "bin/file", + expr.interpolate([[{{value | strip_suffix(".tar.gz") }}]], { + value = "bin/file.tar.gz", + }) + ) + end) +end) + describe("table interpolation", function() it("should interpolate nested values", function() assert.same( |
