concatUrl static method

String concatUrl(
  1. String currentUrl,
  2. dynamic suffixUrl
)

Implementation

static String concatUrl(String currentUrl, dynamic suffixUrl) {
  if (suffixUrl == null) {
    return currentUrl;
  }

  String parsedSuffixUrl = suffixUrl.toString();

  if (parsedSuffixUrl.isEmpty) {
    return currentUrl;
  }

  if (currentUrl.endsWith("/")) {
    currentUrl = currentUrl.substring(0, currentUrl.length - 1);
  }

  if (parsedSuffixUrl.startsWith("/")) {
    parsedSuffixUrl = parsedSuffixUrl.substring(1, parsedSuffixUrl.length);
  }

  return '$currentUrl/$parsedSuffixUrl';
}