Skip to content

Commit 87eb3ac

Browse files
authored
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`).
1 parent cd7835b commit 87eb3ac

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lua/mason-registry/sources/init.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@ local _ = require "mason-core.functional"
22

33
local M = {}
44

5+
---@param str string
6+
local function split_once_left(str, char)
7+
for i = 1, #str do
8+
if str:sub(i, i) == char then
9+
local segment = str:sub(1, i - 1)
10+
return segment, str:sub(i + 1)
11+
end
12+
end
13+
return str
14+
end
15+
516
---@param registry_id string
617
---@return fun(): RegistrySource # Thunk to instantiate provider.
718
local function parse(registry_id)
8-
local type, id = registry_id:match "^(.+):(.+)$"
19+
local type, id = split_once_left(registry_id, ":")
920
if type == "github" then
1021
local namespace, name = id:match "^(.+)/(.+)$"
1122
if not namespace or not name then

0 commit comments

Comments
 (0)