rewritePath method

String rewritePath (
  1. String path,
  2. String rootpath
)

Implementation

String rewritePath(String path, String rootpath) {
  final _rootpath = rootpath ?? '';
  var newPath = normalizePath(_rootpath + path);

  // If a path was explicit relative and the rootpath was not an absolute path
  // we must ensure that the new path is also explicit relative.
  if (isPathLocalRelative(path) &&
      isPathRelative(_rootpath) &&
      !isPathLocalRelative(newPath)) {
    newPath = './$newPath';
  }

  return newPath;

// 3.7.1 20180718
//  contexts.Eval.prototype.rewritePath = function (path, rootpath) {
//      var newPath;
//
//      rootpath = rootpath || '';
//      newPath = this.normalizePath(rootpath + path);
//
//      // If a path was explicit relative and the rootpath was not an absolute path
//      // we must ensure that the new path is also explicit relative.
//      if (isPathLocalRelative(path) &&
//          isPathRelative(rootpath) &&
//          isPathLocalRelative(newPath) === false) {
//          newPath = './' + newPath;
//      }
//
//      return newPath;
//  };
}