mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-25656] Adds a function to allow to update assets subpath in a given directory (#15020)
This commit is contained in:
committed by
GitHub
parent
4c64cec948
commit
42657fafa1
@@ -45,14 +45,14 @@ func GetSubpathScriptHash(subpath string) string {
|
||||
return fmt.Sprintf(" 'sha256-%s'", base64.StdEncoding.EncodeToString(scriptHash[:]))
|
||||
}
|
||||
|
||||
// UpdateAssetsSubpath rewrites assets in the /client directory to assume the application is hosted
|
||||
// at the given subpath instead of at the root. No changes are written unless necessary.
|
||||
func UpdateAssetsSubpath(subpath string) error {
|
||||
// UpdateAssetsSubpathInDir rewrites assets in the given directory to assume the application is
|
||||
// hosted at the given subpath instead of at the root. No changes are written unless necessary.
|
||||
func UpdateAssetsSubpathInDir(subpath, directory string) error {
|
||||
if subpath == "" {
|
||||
subpath = "/"
|
||||
}
|
||||
|
||||
staticDir, found := fileutils.FindDir(model.CLIENT_DIR)
|
||||
staticDir, found := fileutils.FindDir(directory)
|
||||
if !found {
|
||||
return errors.New("failed to find client dir")
|
||||
}
|
||||
@@ -139,6 +139,12 @@ func UpdateAssetsSubpath(subpath string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateAssetsSubpath rewrites assets in the /client directory to assume the application is hosted
|
||||
// at the given subpath instead of at the root. No changes are written unless necessary.
|
||||
func UpdateAssetsSubpath(subpath string) error {
|
||||
return UpdateAssetsSubpathInDir(subpath, model.CLIENT_DIR)
|
||||
}
|
||||
|
||||
// UpdateAssetsSubpathFromConfig uses UpdateAssetsSubpath and any path defined in the SiteURL.
|
||||
func UpdateAssetsSubpathFromConfig(config *model.Config) error {
|
||||
// Don't rewrite in development environments, since webpack in developer mode constantly
|
||||
|
||||
Reference in New Issue
Block a user