normalize method

String normalize (String path)

Normalizes path, simplifying it by handling .., and ., and removing redundant path separators whenever possible.

Note that this is not guaranteed to return the same result for two equivalent input paths. For that, see canonicalize. Or, if you're using paths as map keys, pass equals and hash to new HashMap.

context.normalize('path/./to/..//file.text'); // -> 'path/file.txt'

Implementation

String normalize(String path) {
  if (!_needsNormalization(path)) return path;

  var parsed = _parse(path);
  parsed.normalize();
  return parsed.toString();
}