mirror of
https://github.com/lobehub/lobehub
synced 2026-04-21 17:47:27 +00:00
29 lines
781 B
TypeScript
29 lines
781 B
TypeScript
export const parserPluginSettings = (
|
||
settingsStr?: string,
|
||
): Record<string, Record<string, string>> => {
|
||
if (!settingsStr) return {};
|
||
|
||
const settings = new Map();
|
||
|
||
const array = settingsStr.split(/[,,]/).filter(Boolean);
|
||
|
||
for (const item of array) {
|
||
const [id, pluginSettingsStr] = item.split(':');
|
||
if (!id) continue;
|
||
|
||
const pluginSettingItems = pluginSettingsStr.split(';');
|
||
|
||
const cleanId = id.trim();
|
||
|
||
for (const item of pluginSettingItems) {
|
||
const [key, value] = item.split('=');
|
||
if (!key || !value) continue;
|
||
const cleanKey = key.trim();
|
||
const cleanValue = value.trim();
|
||
|
||
settings.set(cleanId, { ...settings.get(cleanId), [cleanKey]: cleanValue });
|
||
}
|
||
}
|
||
|
||
return Object.fromEntries(settings.entries());
|
||
};
|