canonicalUriFor function

String canonicalUriFor (AssetId id)

Returns a canonical uri for id.

If id is under a lib directory then this returns a package: uri, otherwise it just returns id#path.

Implementation

String canonicalUriFor(AssetId id) {
  if (topLevelDir(id.path) == 'lib') {
    var packagePath =
        p.url.join(id.package, p.url.joinAll(p.url.split(id.path).skip(1)));
    return 'package:$packagePath';
  } else {
    return id.path;
  }
}