fix(url_resolver): always replace `package:` in Dart, even if it came from `baseUrl`.
Closes #4775
This commit is contained in:
parent
5256457144
commit
fd9b67537d
|
@ -1,6 +1,10 @@
|
||||||
library angular2.src.services.url_resolver;
|
library angular2.src.services.url_resolver;
|
||||||
|
|
||||||
import 'package:angular2/src/core/di.dart' show Injectable;
|
import 'package:angular2/src/core/di.dart' show Injectable, Provider;
|
||||||
|
|
||||||
|
UrlResolver createWithoutPackagePrefix() {
|
||||||
|
return new UrlResolver.withUrlPrefix(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
class UrlResolver {
|
class UrlResolver {
|
||||||
|
@ -28,14 +32,15 @@ class UrlResolver {
|
||||||
*/
|
*/
|
||||||
String resolve(String baseUrl, String url) {
|
String resolve(String baseUrl, String url) {
|
||||||
Uri uri = Uri.parse(url);
|
Uri uri = Uri.parse(url);
|
||||||
|
if (!uri.isAbsolute) {
|
||||||
if (uri.scheme == 'package') {
|
Uri baseUri = Uri.parse(baseUrl);
|
||||||
return '$_packagePrefix/${uri.path}';
|
uri = baseUri.resolveUri(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uri.isAbsolute) return uri.toString();
|
if (_packagePrefix != null && uri.scheme == 'package') {
|
||||||
|
return '$_packagePrefix/${uri.path}';
|
||||||
Uri baseUri = Uri.parse(baseUrl);
|
} else {
|
||||||
return baseUri.resolveUri(uri).toString();
|
return uri.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,11 @@ import {isPresent, isBlank, RegExpWrapper, normalizeBlank} from 'angular2/src/co
|
||||||
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
|
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
|
||||||
import {ListWrapper} from 'angular2/src/core/facade/collection';
|
import {ListWrapper} from 'angular2/src/core/facade/collection';
|
||||||
|
|
||||||
|
export function createWithoutPackagePrefix(): UrlResolver {
|
||||||
|
return new UrlResolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by the {@link Compiler} when resolving HTML and CSS template URLs.
|
* Used by the {@link Compiler} when resolving HTML and CSS template URLs.
|
||||||
*
|
*
|
||||||
|
|
|
@ -3,8 +3,10 @@ import {MockSchemaRegistry} from './schema_registry_mock';
|
||||||
import {ElementSchemaRegistry} from 'angular2/src/core/compiler/schema/element_schema_registry';
|
import {ElementSchemaRegistry} from 'angular2/src/core/compiler/schema/element_schema_registry';
|
||||||
import {MockXHR} from 'angular2/src/core/compiler/xhr_mock';
|
import {MockXHR} from 'angular2/src/core/compiler/xhr_mock';
|
||||||
import {XHR} from 'angular2/src/core/compiler/xhr';
|
import {XHR} from 'angular2/src/core/compiler/xhr';
|
||||||
|
import {UrlResolver, createWithoutPackagePrefix} from 'angular2/src/core/compiler/url_resolver';
|
||||||
|
|
||||||
export var TEST_PROVIDERS = [
|
export var TEST_PROVIDERS = [
|
||||||
provide(ElementSchemaRegistry, {useValue: new MockSchemaRegistry({}, {})}),
|
provide(ElementSchemaRegistry, {useValue: new MockSchemaRegistry({}, {})}),
|
||||||
provide(XHR, {useClass: MockXHR})
|
provide(XHR, {useClass: MockXHR}),
|
||||||
|
provide(UrlResolver, {useFactory: createWithoutPackagePrefix})
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue