diff options
| -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( |
