endpointNorm function

String endpointNorm(
  1. List<String> paths, {
  2. bool normSlashs = true,
  3. dynamic endWithSlash = true,
  4. dynamic startWithSlash = true,
})

Implementation

String endpointNorm(
  List<String> paths, {
  bool normSlashs = true,
  endWithSlash = true,
  startWithSlash = true,
}) {
  var path = joinPaths(paths);
  if (endWithSlash && !path.endsWith('/')) {
    path += '/';
  }

  if (startWithSlash && !path.startsWith('/')) {
    path = '/$path';
  }

  if (normSlashs) {
    path = path.replaceAll('\\', '/');
  }
  path = path.replaceAll('//', '/');
  return path;
}