| Index: pkg/polymer/lib/src/build/import_inliner.dart
|
| diff --git a/pkg/polymer/lib/src/build/import_inliner.dart b/pkg/polymer/lib/src/build/import_inliner.dart
|
| index 675db2999d793603aebda86e8799a5b407a7ecd9..9136118b3507ecff9885700672d40cd9dad30972 100644
|
| --- a/pkg/polymer/lib/src/build/import_inliner.dart
|
| +++ b/pkg/polymer/lib/src/build/import_inliner.dart
|
| @@ -417,10 +417,12 @@ class _UrlNormalizer extends TreeVisitor {
|
| }
|
|
|
| String _newUrl(String href, Span span) {
|
| - // Uri.parse blows up on invalid characters (like {{). Encoding the uri
|
| - // allows it to be parsed, which does the correct thing in the general case.
|
| - // This uri not used to build the new uri, so it never needs to be decoded.
|
| - var uri = Uri.parse(Uri.encodeFull(href));
|
| + // Take all bindings out of the path and replace with [BINDING_PLACEHOLDER]
|
| + // so [Uri.parse] will not fail.
|
| + var bindingMatches = BINDING_REGEX.allMatches(href).map((m) => m.group(0));
|
| + href = href.replaceAll(BINDING_REGEX, BINDING_PLACEHOLDER);
|
| +
|
| + var uri = Uri.parse(href);
|
| if (uri.isAbsolute) return href;
|
| if (!uri.scheme.isEmpty) return href;
|
| if (!uri.host.isEmpty) return href;
|
| @@ -431,12 +433,18 @@ class _UrlNormalizer extends TreeVisitor {
|
| if (id == null) return href;
|
| var primaryId = transform.primaryInput.id;
|
|
|
| - if (id.path.startsWith('lib/')) {
|
| - return '${topLevelPath}packages/${id.package}/${id.path.substring(4)}';
|
| + // Put the original bindings back into the path now that we have parsed it.
|
| + var newPath = id.path;
|
| + for (var bindingMatch in bindingMatches) {
|
| + newPath = newPath.replaceFirst(BINDING_PLACEHOLDER, bindingMatch);
|
| + }
|
| +
|
| + if (newPath.startsWith('lib/')) {
|
| + return '${topLevelPath}packages/${id.package}/${newPath.substring(4)}';
|
| }
|
|
|
| - if (id.path.startsWith('asset/')) {
|
| - return '${topLevelPath}assets/${id.package}/${id.path.substring(6)}';
|
| + if (newPath.startsWith('asset/')) {
|
| + return '${topLevelPath}assets/${id.package}/${newPath.substring(6)}';
|
| }
|
|
|
| if (primaryId.package != id.package) {
|
| @@ -447,7 +455,7 @@ class _UrlNormalizer extends TreeVisitor {
|
| }
|
|
|
| var builder = path.url;
|
| - return builder.relative(builder.join('/', id.path),
|
| + return builder.relative(builder.join('/', newPath),
|
| from: builder.join('/', builder.dirname(primaryId.path)));
|
| }
|
| }
|
| @@ -476,8 +484,12 @@ const _urlAttributes = const [
|
| const IGNORED_LINKED_STYLE_ATTRS =
|
| const ['charset', 'href', 'href-lang', 'rel', 'rev'];
|
|
|
| -/// Global RegExp objects for validating generated library names.
|
| +/// Global RegExp objects.
|
| final INVALID_LIB_CHARS_REGEX = new RegExp('[^a-z0-9_]');
|
| final NUM_REGEX = new RegExp('[0-9]');
|
| +final BINDING_REGEX = new RegExp(r'({{.*}})');
|
| +
|
| +/// Placeholder for bindings in urls for [Uri.parse].
|
| +final BINDING_PLACEHOLDER = '%BINDING%';
|
|
|
| _getSpan(SourceFile file, AstNode node) => file.span(node.offset, node.end);
|
|
|