root property
String
get
root
prefix with its slashes tidied — no leading or trailing one, . and the
empty string both meaning the whole package.
Every comparison goes through this rather than through prefix itself, so
demo/, /demo and demo are one rule and not three.
Implementation
String get root {
var trimmed = prefix.trim();
if (trimmed == '.' || trimmed == '/') return '';
var start = trimmed.startsWith('/') ? 1 : 0;
var end = trimmed.endsWith('/') ? trimmed.length - 1 : trimmed.length;
return start >= end ? '' : trimmed.substring(start, end);
}