From 87eb3ac2ab4fcbf5326d8bde6842b073a3be65a7 Mon Sep 17 00:00:00 2001 From: William Boman Date: Tue, 31 Oct 2023 15:55:27 +0100 Subject: 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`). --- lua/mason-registry/sources/init.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lua/mason-registry/sources/init.lua') 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 -- cgit v1.2.3-70-g09d2