stripTrailingSlash function Null safety

String stripTrailingSlash (
  1. String path
)

Removes the trailing forward slash from path if any.

Implementation

String stripTrailingSlash(String path) {
  if (path.endsWith('/')) {
    return path.substring(0, path.length - 1);
  }
  return path;
}