Skip to content

Commit

Permalink
fix(registry): fix parsing registry identifiers that contain ":" (#1542)
Browse files Browse the repository at this point in the history
This primarily fixes `file:` registry identifiers on Windows that may include a drive letter (e.g.
`file:C:\Users\user\AppData\Local\nvim`).
  • Loading branch information
williamboman committed Oct 31, 2023
1 parent cd7835b commit 87eb3ac
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lua/mason-registry/sources/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 87eb3ac

Please sign in to comment.