removeTrailingSlash function

String removeTrailingSlash(
  1. String path
)

Removes a trailing slash from the path if it has one.

Implementation

String removeTrailingSlash(String path) {
  if (Platform.isWindows) {
    if (isDriveRoot(path)) {
      return addTrailingSlash(path);
    }
  }
  if (path != '/' && path.endsWith(kPathSeparator)) {
    return path.substring(0, path.length - 1);
  }
  return path;
}