Commit ccf1a512 by Daniel Lee

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.
parent 27835f37
...@@ -40,7 +40,7 @@ func getPluginLogoUrl(pluginType, path, baseUrl string) string { ...@@ -40,7 +40,7 @@ func getPluginLogoUrl(pluginType, path, baseUrl string) string {
} }
func (fp *FrontendPluginBase) setPathsBasedOnApp(app *AppPlugin) { 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.IncludedInAppId = app.Id
fp.BaseUrl = app.BaseUrl fp.BaseUrl = app.BaseUrl
......
...@@ -14,7 +14,7 @@ func TestFrontendPlugin(t *testing.T) { ...@@ -14,7 +14,7 @@ func TestFrontendPlugin(t *testing.T) {
fp := &FrontendPluginBase{ fp := &FrontendPluginBase{
PluginBase: PluginBase{ PluginBase: PluginBase{
PluginDir: "c:\\grafana\\public\\app\\plugins\\app\\testdata\\datasource", PluginDir: "c:\\grafana\\public\\app\\plugins\\app\\testdata\\datasources\\datasource",
BaseUrl: "fpbase", BaseUrl: "fpbase",
}, },
} }
...@@ -29,6 +29,6 @@ func TestFrontendPlugin(t *testing.T) { ...@@ -29,6 +29,6 @@ func TestFrontendPlugin(t *testing.T) {
} }
fp.setPathsBasedOnApp(app) fp.setPathsBasedOnApp(app)
So(fp.Module, ShouldEqual, "app/plugins/app/testdata/datasource/module") So(fp.Module, ShouldEqual, "app/plugins/app/testdata/datasources/datasource/module")
}) })
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment