[MM-25656] Adds a function to allow to update assets subpath in a given directory (#15020)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
4c64cec948
Коммит
42657fafa1
@@ -45,14 +45,14 @@ func GetSubpathScriptHash(subpath string) string {
|
|||||||
return fmt.Sprintf(" 'sha256-%s'", base64.StdEncoding.EncodeToString(scriptHash[:]))
|
return fmt.Sprintf(" 'sha256-%s'", base64.StdEncoding.EncodeToString(scriptHash[:]))
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateAssetsSubpath rewrites assets in the /client directory to assume the application is hosted
|
// UpdateAssetsSubpathInDir rewrites assets in the given directory to assume the application is
|
||||||
// at the given subpath instead of at the root. No changes are written unless necessary.
|
// hosted at the given subpath instead of at the root. No changes are written unless necessary.
|
||||||
func UpdateAssetsSubpath(subpath string) error {
|
func UpdateAssetsSubpathInDir(subpath, directory string) error {
|
||||||
if subpath == "" {
|
if subpath == "" {
|
||||||
subpath = "/"
|
subpath = "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
staticDir, found := fileutils.FindDir(model.CLIENT_DIR)
|
staticDir, found := fileutils.FindDir(directory)
|
||||||
if !found {
|
if !found {
|
||||||
return errors.New("failed to find client dir")
|
return errors.New("failed to find client dir")
|
||||||
}
|
}
|
||||||
@@ -139,6 +139,12 @@ func UpdateAssetsSubpath(subpath string) error {
|
|||||||
return nil
|
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.
|
// UpdateAssetsSubpathFromConfig uses UpdateAssetsSubpath and any path defined in the SiteURL.
|
||||||
func UpdateAssetsSubpathFromConfig(config *model.Config) error {
|
func UpdateAssetsSubpathFromConfig(config *model.Config) error {
|
||||||
// Don't rewrite in development environments, since webpack in developer mode constantly
|
// Don't rewrite in development environments, since webpack in developer mode constantly
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user