rootPrefix method
- String path
Returns the root of path
if it's absolute, or an empty string if it's
relative.
// Unix
context.rootPrefix('path/to/foo'); // -> ''
context.rootPrefix('/path/to/foo'); // -> '/'
// Windows
context.rootPrefix(r'path\to\foo'); // -> ''
context.rootPrefix(r'C:\path\to\foo'); // -> r'C:\'
context.rootPrefix(r'\\server\share\a\b'); // -> r'\\server\share'
// URL
context.rootPrefix('path/to/foo'); // -> ''
context.rootPrefix('https://dart.cn/path/to/foo');
// -> 'https://dart.cn'
Implementation
String rootPrefix(String path) => path.substring(0, style.rootLength(path));