fix(url_resolver): in Dart make package urls relative to AppRootUrl
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
library angular2.src.services.url_resolver;
|
||||
|
||||
import 'package:angular2/di.dart' show Injectable;
|
||||
import 'package:angular2/src/services/app_root_url.dart' show AppRootUrl;
|
||||
|
||||
@Injectable()
|
||||
class UrlResolver {
|
||||
|
||||
final AppRootUrl _appRootUrl;
|
||||
|
||||
UrlResolver(this._appRootUrl);
|
||||
|
||||
/**
|
||||
* Resolves the `url` given the `baseUrl`:
|
||||
* - when the `url` is null, the `baseUrl` is returned,
|
||||
@@ -20,7 +26,8 @@ class UrlResolver {
|
||||
Uri uri = Uri.parse(url);
|
||||
|
||||
if (uri.scheme == 'package') {
|
||||
return '/packages/${uri.path}';
|
||||
var maybeSlash = _appRootUrl.value.endsWith('/') ? '' : '/';
|
||||
return '${_appRootUrl.value}${maybeSlash}packages/${uri.path}';
|
||||
}
|
||||
|
||||
if (uri.isAbsolute) return uri.toString();
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
normalizeBlank
|
||||
} from 'angular2/src/facade/lang';
|
||||
import {ListWrapper} from 'angular2/src/facade/collection';
|
||||
import {AppRootUrl} from 'angular2/src/services/app_root_url';
|
||||
|
||||
/**
|
||||
* Used by the {@link Compiler} when resolving HTML and CSS template URLs.
|
||||
@@ -17,6 +18,8 @@ import {ListWrapper} from 'angular2/src/facade/collection';
|
||||
*/
|
||||
@Injectable()
|
||||
export class UrlResolver {
|
||||
constructor(_: AppRootUrl) {}
|
||||
|
||||
/**
|
||||
* Resolves the `url` given the `baseUrl`:
|
||||
* - when the `url` is null, the `baseUrl` is returned,
|
||||
|
||||
Reference in New Issue
Block a user