rootPrefix function

String rootPrefix(
  1. String path
)

Returns the root of path, if it's absolute, or the empty string if it's relative.

// Unix
p.rootPrefix('path/to/foo'); // -> ''
p.rootPrefix('/path/to/foo'); // -> '/'

// Windows
p.rootPrefix(r'path\to\foo'); // -> ''
p.rootPrefix(r'C:\path\to\foo'); // -> r'C:\'
p.rootPrefix(r'\\server\share\a\b'); // -> r'\\server\share'

// URL
p.rootPrefix('path/to/foo'); // -> ''
p.rootPrefix('https://dart.cn/path/to/foo');
  // -> 'https://dart.cn'

Implementation

String rootPrefix(String path) => context.rootPrefix(path);