X Tutup
Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion modules/angular2/src/services/url_resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ import 'package:angular2/di.dart' show Injectable;

@Injectable()
class UrlResolver {
/// This will be the location where 'package:' Urls will resolve. Default is
/// '/packages'
final String packagePrefix;

const UrlResolver() : packagePrefix = '/packages';

/// Creates a UrlResolver that will resolve 'package:' Urls to a different
/// prefixed location.
const UrlResolver.withUrlPrefix(this.packagePrefix);

/**
* Resolves the `url` given the `baseUrl`:
* - when the `url` is null, the `baseUrl` is returned,
Expand All @@ -20,7 +30,7 @@ class UrlResolver {
Uri uri = Uri.parse(url);

if (uri.scheme == 'package') {
return '/packages/${uri.path}';
return '$packagePrefix/${uri.path}';
}

if (uri.isAbsolute) return uri.toString();
Expand Down
X Tutup