Skip to content

Commit

Permalink
Fix handling of empty 'urlsToWatch' in plugins (#533)
Browse files Browse the repository at this point in the history
* When plugin defines an empty array of URLs to watch, use the global one #527

* Refactor plugin registration on line 55 to check for both null and non-empty 'pluginUrls'. This ensures proper handling of empty plugin URL arrays and aligns with the requirement outlined in the issue. Updated the 'Register' method call to conditionally use 'pluginUrls' or default to 'defaultUrlsToWatch' based on the not null and not empty check. #528

* Fix handling of empty 'urlsToWatch' in plugins

This commit addresses the issue where plugins defining an empty array for 'urlsToWatch' would result in the plugin being disabled. The code has been modified to check for both null and empty arrays, and in both cases, it now defaults to using the global list of URLs. This ensures that plugins remain active even when no specific URLs are provided.

* Update dev-proxy/PluginLoader.cs

---------

Co-authored-by: Waldek Mastykarz <[email protected]>
  • Loading branch information
SilentSobs and waldekmastykarz authored Jan 29, 2024
1 parent a6d0662 commit 361a0df
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dev-proxy/PluginLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ public PluginLoaderResult LoadPlugins(IPluginEvents pluginEvents, IProxyContext
}
// Load Plugins from assembly
IProxyPlugin plugin = CreatePlugin(assembly, h);
plugin.Register(pluginEvents, proxyContext, pluginUrls ?? defaultUrlsToWatch, h.ConfigSection is null ? null : Configuration.GetSection(h.ConfigSection));
plugin.Register(
pluginEvents,
proxyContext,
(pluginUrls != null && pluginUrls.Any()) ? pluginUrls : defaultUrlsToWatch,
h.ConfigSection is null ? null : Configuration.GetSection(h.ConfigSection)
);
plugins.Add(plugin);
}
}
Expand Down

0 comments on commit 361a0df

Please sign in to comment.