toUri method

Uri toUri (String path)

Returns the URI that represents path.

For POSIX and Windows styles, this will return a file: URI. For the URL style, this will just convert path to a Uri.

// POSIX
context.toUri('/path/to/foo')
  // -> Uri.parse('file:///path/to/foo')

// Windows
context.toUri(r'C:\path\to\foo')
  // -> Uri.parse('file:///C:/path/to/foo')

// URL
context.toUri('http://dartlang.org/path/to/foo')
  // -> Uri.parse('http://dartlang.org/path/to/foo')

Implementation

Uri toUri(String path) {
  if (isRelative(path)) {
    return style.relativePathToUri(path);
  } else {
    return style.absolutePathToUri(join(current, path));
  }
}