{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/8522","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/8522/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/8522/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/8522/events","html_url":"https://github.com/yiisoft/yii2/issues/8522","id":79475682,"number":8522,"title":"AssetManager not work correctly with Relative URL in getAssetUrl method by assetMap.","user":{"login":"porshkevich","id":8709638,"avatar_url":"https://avatars.githubusercontent.com/u/8709638?v=3","gravatar_id":"","url":"https://api.github.com/users/porshkevich","html_url":"https://github.com/porshkevich","followers_url":"https://api.github.com/users/porshkevich/followers","following_url":"https://api.github.com/users/porshkevich/following{/other_user}","gists_url":"https://api.github.com/users/porshkevich/gists{/gist_id}","starred_url":"https://api.github.com/users/porshkevich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/porshkevich/subscriptions","organizations_url":"https://api.github.com/users/porshkevich/orgs","repos_url":"https://api.github.com/users/porshkevich/repos","events_url":"https://api.github.com/users/porshkevich/events{/privacy}","received_events_url":"https://api.github.com/users/porshkevich/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yiisoft/yii2/labels/status:under%20discussion","name":"status:under discussion","color":"f7c6c7"},{"url":"https://api.github.com/repos/yiisoft/yii2/labels/type:enhancement","name":"type:enhancement","color":"d7e102"}],"state":"closed","locked":false,"assignee":{"login":"klimov-paul","id":1482054,"avatar_url":"https://avatars.githubusercontent.com/u/1482054?v=3","gravatar_id":"","url":"https://api.github.com/users/klimov-paul","html_url":"https://github.com/klimov-paul","followers_url":"https://api.github.com/users/klimov-paul/followers","following_url":"https://api.github.com/users/klimov-paul/following{/other_user}","gists_url":"https://api.github.com/users/klimov-paul/gists{/gist_id}","starred_url":"https://api.github.com/users/klimov-paul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klimov-paul/subscriptions","organizations_url":"https://api.github.com/users/klimov-paul/orgs","repos_url":"https://api.github.com/users/klimov-paul/repos","events_url":"https://api.github.com/users/klimov-paul/events{/privacy}","received_events_url":"https://api.github.com/users/klimov-paul/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/yiisoft/yii2/milestones/13","html_url":"https://github.com/yiisoft/yii2/milestones/2.0.5","labels_url":"https://api.github.com/repos/yiisoft/yii2/milestones/13/labels","id":1000704,"number":13,"title":"2.0.5","description":"","creator":{"login":"qiangxue","id":993322,"avatar_url":"https://avatars.githubusercontent.com/u/993322?v=3","gravatar_id":"","url":"https://api.github.com/users/qiangxue","html_url":"https://github.com/qiangxue","followers_url":"https://api.github.com/users/qiangxue/followers","following_url":"https://api.github.com/users/qiangxue/following{/other_user}","gists_url":"https://api.github.com/users/qiangxue/gists{/gist_id}","starred_url":"https://api.github.com/users/qiangxue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qiangxue/subscriptions","organizations_url":"https://api.github.com/users/qiangxue/orgs","repos_url":"https://api.github.com/users/qiangxue/repos","events_url":"https://api.github.com/users/qiangxue/events{/privacy}","received_events_url":"https://api.github.com/users/qiangxue/received_events","type":"User","site_admin":false},"open_issues":58,"closed_issues":41,"state":"open","created_at":"2015-03-01T16:03:07Z","updated_at":"2015-05-28T13:42:36Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2015-05-22T14:28:07Z","updated_at":"2015-05-28T13:42:36Z","closed_at":"2015-05-28T13:42:36Z","body":"In base by assetMap we can change asset url to Relative URL.\r\nBut AssetManager use only 2 rule for that changing\r\n1. Base rule. (BaseUrl + AssetUrl)\r\n2. A relative URL that begins with // (two slashes) always replaces everything from the hostname onwards. \r\n\r\nand forget about the third rule\r\n3. A relative URL that begins with / (a slash) always replaces the entire pathname of the base URL. \r\n\r\nI propose to change\r\n```php\r\npublic function getAssetUrl($bundle, $asset)\r\n    {\r\n        if (($actualAsset = $this->resolveAsset($bundle, $asset)) !== false) {\r\n            return Url::isRelative($actualAsset) ? $this->baseUrl . '/' . $actualAsset : $actualAsset;\r\n        } else {\r\n            return Url::isRelative($asset) ? $bundle->baseUrl . '/' . $asset : $asset;\r\n        }\r\n    }\r\n```\r\nto\r\n```php\r\npublic function getAssetUrl($bundle, $asset)\r\n    {\r\n        if (($actualAsset = $this->resolveAsset($bundle, $asset)) !== false) {\r\n            return Url::isRelative($actualAsset) && strncmp($actualAsset, '/', 1) ? $this->baseUrl . '/' . $actualAsset : $actualAsset;\r\n        } else {\r\n            return Url::isRelative($asset) ? $bundle->baseUrl . '/' . $asset : $asset;\r\n        }\r\n    }\r\n```\r\nThis will be used for such substitution by assetMap like\r\n\r\nassetMap value | genaretad url | result url\r\n-------------------- | ----------------- | -----------\r\njs/jquery.js | $baseUrl/js/jquery.js | http://sitehost/path/to/baseUrl/js/jquery.js\r\n/js/jquery.js | /js/jquery.js | http://sitehost/js/jquery.js\r\n//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js | //ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js | http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js\r\n"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/106315310","html_url":"https://github.com/yiisoft/yii2/issues/8522#issuecomment-106315310","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/8522","id":106315310,"user":{"login":"klimov-paul","id":1482054,"avatar_url":"https://avatars.githubusercontent.com/u/1482054?v=3","gravatar_id":"","url":"https://api.github.com/users/klimov-paul","html_url":"https://github.com/klimov-paul","followers_url":"https://api.github.com/users/klimov-paul/followers","following_url":"https://api.github.com/users/klimov-paul/following{/other_user}","gists_url":"https://api.github.com/users/klimov-paul/gists{/gist_id}","starred_url":"https://api.github.com/users/klimov-paul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klimov-paul/subscriptions","organizations_url":"https://api.github.com/users/klimov-paul/orgs","repos_url":"https://api.github.com/users/klimov-paul/repos","events_url":"https://api.github.com/users/klimov-paul/events{/privacy}","received_events_url":"https://api.github.com/users/klimov-paul/received_events","type":"User","site_admin":false},"created_at":"2015-05-28T13:42:36Z","updated_at":"2015-05-28T13:42:36Z","body":"Issue resolved by commit 95ba06c"}}