diff options
author | dizzy <diosmosis@users.noreply.github.com> | 2022-06-21 10:40:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-21 10:40:55 +0300 |
commit | a6b8786a35b83e1967dd0bb92ff6f1e1acb47907 (patch) | |
tree | da70519f5a0f87120aa057b63e83204f492f3acb /core | |
parent | d22f787ff61b3547c948c76bdfbe5a478a3a5185 (diff) |
[Vue] when getting plugin path relative to webroot, try all possible webroots (#19362)
* when getting plugin path relative to webroot, try all possible webroots
* use key values of array
* replace absolute path w/ path relative to matomo root to get it to work
* fix test
* remove leading slashes
Diffstat (limited to 'core')
-rw-r--r-- | core/AssetManager/UIAssetFetcher/PluginUmdAssetFetcher.php | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/core/AssetManager/UIAssetFetcher/PluginUmdAssetFetcher.php b/core/AssetManager/UIAssetFetcher/PluginUmdAssetFetcher.php index 9ac1edaec7..bfd73ca039 100644 --- a/core/AssetManager/UIAssetFetcher/PluginUmdAssetFetcher.php +++ b/core/AssetManager/UIAssetFetcher/PluginUmdAssetFetcher.php @@ -276,7 +276,22 @@ class PluginUmdAssetFetcher extends UIAssetFetcher private static function getRelativePluginDirectory($plugin) { $result = self::getPluginDirectory($plugin); - $result = str_replace(PIWIK_INCLUDE_PATH . '/', '', $result); + + $matomoPath = rtrim(PIWIK_INCLUDE_PATH, '/') . '/'; + $webroots = array_merge( + Manager::getAlternativeWebRootDirectories(), + [$matomoPath => '/'] + ); + + foreach ($webroots as $webrootAbsolute => $webrootRelative) { + if (strpos($result, $webrootAbsolute) === 0) { + $result = str_replace($webrootAbsolute, $webrootRelative, $result); + break; + } + } + + $result = ltrim($result, '/'); + return $result; } |