Browse Source

Fixes #2399: Fixed the bug that AssetBundle did not handle relative URLs correctly

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
65a8eae717
  1. 1
      framework/CHANGELOG.md
  2. 5
      framework/web/AssetBundle.php

1
framework/CHANGELOG.md

@ -45,6 +45,7 @@ Yii Framework 2 Change Log
- Bug #2298: Fixed the bug that Gii controller generator did not allow digit in the controller ID (qiangxue)
- Bug #2303: Fixed the bug that `yii\base\Theme::pathMap` did not support dynamic update with path aliases (qiangxue)
- Bug #2324: Fixed QueryBuilder bug when building a query with "query" option (mintao)
- Bug #2399: Fixed the bug that AssetBundle did not handle relative URLs correctly (qiangxue)
- Bug: Fixed `Call to a member function registerAssetFiles() on a non-object` in case of wrong `sourcePath` for an asset bundle (samdark)
- Bug: Fixed incorrect event name for `yii\jui\Spinner` (samdark)
- Bug: Json::encode() did not handle objects that implement JsonSerializable interface correctly (cebe)

5
framework/web/AssetBundle.php

@ -170,12 +170,13 @@ class AssetBundle extends Object
list ($this->basePath, $this->baseUrl) = $am->publish($this->sourcePath, $this->publishOptions);
}
$converter = $am->getConverter();
$baseUrl = Yii::$app->getRequest()->getBaseUrl();
foreach ($this->js as $i => $js) {
if (strpos($js, '/') !== 0 && strpos($js, '://') === false) {
if (isset($this->basePath, $this->baseUrl)) {
$this->js[$i] = $converter->convert($js, $this->basePath, $this->baseUrl);
} else {
$this->js[$i] = '/' . $js;
$this->js[$i] = $baseUrl . '/' . $js;
}
}
}
@ -184,7 +185,7 @@ class AssetBundle extends Object
if (isset($this->basePath, $this->baseUrl)) {
$this->css[$i] = $converter->convert($css, $this->basePath, $this->baseUrl);
} else {
$this->css[$i] = '/' . $css;
$this->css[$i] = $baseUrl . '/' . $css;
}
}
}

Loading…
Cancel
Save