Skip to content
This repository
Browse code

Honour assets_base_url if used

  • Loading branch information...
commit ee7e2f4a47d88c0bd91ebdafb8001a2eeb82f733 1 parent 343fef4
Steffan Harries authored

Showing 1 changed file with 11 additions and 4 deletions. Show diff stats Hide diff stats

  1. 15  Configuration/ConfigurationBuilder.php
15  Configuration/ConfigurationBuilder.php
@@ -108,18 +108,25 @@ public function setOption($option, $value)
108 108
      */
109 109
     public function getConfiguration()
110 110
     {
111  
-        $rootUrl = '';
112 111
         if ($this->useControllerForAssets && $this->container->isScopeActive('request')) {
113  
-            $rootUrl = $this->container->get('request')->getBaseUrl();
  112
+            $baseUrl = $this->container->get('request')->getBaseUrl();
  113
+            $baseUrl = $baseUrl . '/' . \ltrim($this->baseUrl, '/');
  114
+        } else {
  115
+            $baseUrl = $this->container->get('templating.helper.assets')->getUrl(\ltrim($this->baseUrl, '/'));
  116
+            // remove ?version from end of URL
  117
+            if (($p = strpos($baseUrl, '?')) !== false) {
  118
+                $baseUrl = substr($baseUrl, 0, $p);
  119
+            }
114 120
         }
  121
+
115 122
         $config = array(
116  
-            'baseUrl' => $rootUrl . '/' . \ltrim($this->baseUrl, '/'),
  123
+            'baseUrl' => $baseUrl,
117 124
             'locale' => $this->translator->getLocale(),
118 125
         );
119 126
         if ($this->paths !== null) {
120 127
             $config['paths'] = $this->paths;
121 128
         }
122 129
         return array_merge($config, $this->additionalConfig);
123  
-    }    
  130
+    }
124 131
 
125 132
 }

0 notes on commit ee7e2f4

Please sign in to comment.
Something went wrong with that request. Please try again.