stripStraySlashes function
Removes the leading and trailing slashes of str, as
str.replaceAll(RegExp(r'(^/+)|(/+$)'), '') does, but about 40 times
faster. Only slashes gives ''.
Implementation
String stripStraySlashes(String str) {
var start = 0, end = str.length;
while (start < end && str.codeUnitAt(start) == 0x2F) {
start++;
}
while (end > start && str.codeUnitAt(end - 1) == 0x2F) {
end--;
}
return start == 0 && end == str.length ? str : str.substring(start, end);
}