diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2017-12-28 10:25:10 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2017-12-30 05:55:44 +0100 |
commit | dc938628f7bacd16f88b2cf9cff3f46ec03fc929 (patch) | |
tree | cca14e380db537eac383978cdf6564696e2234f7 /lib | |
parent | ad20af619fa3d71d806c12fb10b418ace9cf0f66 (diff) | |
download | nextcloud-server-dc938628f7bacd16f88b2cf9cff3f46ec03fc929.tar.gz nextcloud-server-dc938628f7bacd16f88b2cf9cff3f46ec03fc929.zip |
Use OC_Util function for app web path
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Template/SCSSCacher.php | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index 300187cf743..0409071102d 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -102,7 +102,7 @@ class SCSSCacher { $fileNameCSS = $this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileNameSCSS)); $path = implode('/', $path); - $webDir = $this->getWebDir($path); + $webDir = $this->getWebDir($path, $app); try { $folder = $this->appData->getFolder($app); @@ -311,20 +311,23 @@ class SCSSCacher { } /** - * Prepend hashed base url to the css file + * Get WebDir root * @param string $path the css file path + * @param string $app the app name * @return string the webDir */ - private function getWebDir($path) { + private function getWebDir($path, $app) { + // Detect if path is within server root + if(strpos($path, $this->serverRoot) > -1) { + return \OC::$WEBROOT.substr($path, strlen($this->serverRoot)); + } // Detect if path is within an app path - $app_paths = $this->config->getSystemValue('apps_paths'); - if (!empty($app_paths)) { - foreach ($app_paths as $app_path) { - if (strpos($path, $app_path["path"]) === 0) { - return $app_path["url"].str_replace($app_path["path"], '', $path); - } - } + if($appWebPath = \OC_App::getAppWebPath($app)) { + // Get the file path within the app directory + $appDirectoryPath = explode($app, $path)[1]; + // Remove the webroot + return str_replace(\OC::$WEBROOT, '', $appWebPath.$appDirectoryPath); } - return substr($path, strlen($this->serverRoot)); + return \OC::$WEBROOT.substr($path, strlen($this->serverRoot)); } } |