From ccf1a5124b53493c05c1d1e856f2d3d45cc5d3ce Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Wed, 3 Jan 2018 22:07:38 +0100 Subject: [PATCH] plugin: fix path for app plugins on windows This fixes when an app that contains a plugin (which means it has a filepath with more parts) gets a back slash in the path for the plugin module. The string replace now replaces all back slashes and not just the first one. --- pkg/plugins/frontend_plugin.go | 2 +- pkg/plugins/frontend_plugin_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/plugins/frontend_plugin.go b/pkg/plugins/frontend_plugin.go index 90c18d90044..04af4060169 100644 --- a/pkg/plugins/frontend_plugin.go +++ b/pkg/plugins/frontend_plugin.go @@ -40,7 +40,7 @@ func getPluginLogoUrl(pluginType, path, baseUrl string) string { } func (fp *FrontendPluginBase) setPathsBasedOnApp(app *AppPlugin) { - appSubPath := strings.Replace(strings.Replace(fp.PluginDir, app.PluginDir, "", 1), "\\", "/", 1) + appSubPath := strings.Replace(strings.Replace(fp.PluginDir, app.PluginDir, "", 1), "\\", "/", -1) fp.IncludedInAppId = app.Id fp.BaseUrl = app.BaseUrl diff --git a/pkg/plugins/frontend_plugin_test.go b/pkg/plugins/frontend_plugin_test.go index 304cd38deae..311f9fcc510 100644 --- a/pkg/plugins/frontend_plugin_test.go +++ b/pkg/plugins/frontend_plugin_test.go @@ -14,7 +14,7 @@ func TestFrontendPlugin(t *testing.T) { fp := &FrontendPluginBase{ PluginBase: PluginBase{ - PluginDir: "c:\\grafana\\public\\app\\plugins\\app\\testdata\\datasource", + PluginDir: "c:\\grafana\\public\\app\\plugins\\app\\testdata\\datasources\\datasource", BaseUrl: "fpbase", }, } @@ -29,6 +29,6 @@ func TestFrontendPlugin(t *testing.T) { } fp.setPathsBasedOnApp(app) - So(fp.Module, ShouldEqual, "app/plugins/app/testdata/datasource/module") + So(fp.Module, ShouldEqual, "app/plugins/app/testdata/datasources/datasource/module") }) }