aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2023-10-31 15:55:27 +0100
committerGitHub <noreply@github.com>2023-10-31 15:55:27 +0100
commit87eb3ac2ab4fcbf5326d8bde6842b073a3be65a7 (patch)
tree8e6658b4ea6303ea78df6cbbbc1e585e7355d2c7
parentchore(main): release 1.8.1 (#1515) (diff)
downloadmason-87eb3ac2ab4fcbf5326d8bde6842b073a3be65a7.tar
mason-87eb3ac2ab4fcbf5326d8bde6842b073a3be65a7.tar.gz
mason-87eb3ac2ab4fcbf5326d8bde6842b073a3be65a7.tar.bz2
mason-87eb3ac2ab4fcbf5326d8bde6842b073a3be65a7.tar.lz
mason-87eb3ac2ab4fcbf5326d8bde6842b073a3be65a7.tar.xz
mason-87eb3ac2ab4fcbf5326d8bde6842b073a3be65a7.tar.zst
mason-87eb3ac2ab4fcbf5326d8bde6842b073a3be65a7.zip
fix(registry): fix parsing registry identifiers that contain ":" (#1542)
This primarily fixes `file:` registry identifiers on Windows that may include a drive letter (e.g. `file:C:\Users\user\AppData\Local\nvim`).
-rw-r--r--lua/mason-registry/sources/init.lua13
1 files changed, 12 insertions, 1 deletions
diff --git a/lua/mason-registry/sources/init.lua b/lua/mason-registry/sources/init.lua
index 953b6ba7..bdaaf38e 100644
--- a/lua/mason-registry/sources/init.lua
+++ b/lua/mason-registry/sources/init.lua
@@ -2,10 +2,21 @@ local _ = require "mason-core.functional"
local M = {}
+---@param str string
+local function split_once_left(str, char)
+ for i = 1, #str do
+ if str:sub(i, i) == char then
+ local segment = str:sub(1, i - 1)
+ return segment, str:sub(i + 1)
+ end
+ end
+ return str
+end
+
---@param registry_id string
---@return fun(): RegistrySource # Thunk to instantiate provider.
local function parse(registry_id)
- local type, id = registry_id:match "^(.+):(.+)$"
+ local type, id = split_once_left(registry_id, ":")
if type == "github" then
local namespace, name = id:match "^(.+)/(.+)$"
if not namespace or not name then