MM-16819 Helper function to build path to plugin asset (#13626)
Implement helper method to create a URL to the resource from a directory
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ee86413cdd
Коммит
8327e9b0ba
@@ -6,6 +6,7 @@ package plugin
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/blang/semver"
|
||||
@@ -54,3 +55,26 @@ func (p *HelpersImpl) ensureServerVersion(required string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetPluginAssetURL implements GetPluginAssetURL.
|
||||
func (p *HelpersImpl) GetPluginAssetURL(pluginID, asset string) (string, error) {
|
||||
if len(pluginID) == 0 {
|
||||
return "", errors.New("empty pluginID provided")
|
||||
}
|
||||
|
||||
if len(asset) == 0 {
|
||||
return "", errors.New("empty asset name provided")
|
||||
}
|
||||
|
||||
siteURL := *p.API.GetConfig().ServiceSettings.SiteURL
|
||||
if siteURL == "" {
|
||||
return "", errors.New("no SiteURL configured by the server")
|
||||
}
|
||||
|
||||
u, err := url.Parse(siteURL + path.Join("/", pluginID, asset))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return u.String(), nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user