Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
feat(relative_url_resolver): Allow configurable package root.
Browse files Browse the repository at this point in the history
Allow the package root to be configurable per application allowing apps that cannot server from
/packages/.
  • Loading branch information
Ted Sander authored and rkirov committed Mar 19, 2015
1 parent 161cf82 commit 62c51a3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/core_dom/resource_url_resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ class ResourceUrlResolver {
// If it's not absolute, then resolve it first
Uri resolved = baseUri.resolve(uri);

// If it's package-relative, tack on '/packages/'
// If it's package-relative, tack on [packageRoot].
if (resolved.scheme == 'package') {
return '/packages/${resolved.path}';
return '${_config.packageRoot}${resolved.path}';
} else if (resolved.isAbsolute && resolved.toString().startsWith(_baseUri)) {
return resolved.path;
} else {
Expand All @@ -181,9 +181,13 @@ class ResourceUrlResolver {

@Injectable()
class ResourceResolverConfig {
static const String DEFAULT_PACKAGE_ROOT = '/packages/';
bool useRelativeUrls;
String packageRoot;

ResourceResolverConfig(): useRelativeUrls = true;
ResourceResolverConfig(): useRelativeUrls = true,
packageRoot = DEFAULT_PACKAGE_ROOT;

ResourceResolverConfig.resolveRelativeUrls(this.useRelativeUrls);
ResourceResolverConfig.resolveRelativeUrls(this.useRelativeUrls,
{this.packageRoot: DEFAULT_PACKAGE_ROOT});
}

0 comments on commit 62c51a3

Please sign in to comment.