getSplitUrlFromString method

List<String>? getSplitUrlFromString()

Implementation

List<String>? getSplitUrlFromString() {
  if(!isValidUri()) {
    return [];
  }

  var splitValue = split("/");
  var index = 0;
  var suffix = "";

  if(contains("http://") || contains("https://")) {

    if(splitValue.length > 3) {

      for (var element in splitValue) {
        if(index >= 3) {
          suffix += "/$element";
        }
        index++;
      }

      var prefixString = replaceAll(suffix, "");
      return [
        prefixString, suffix
      ];
    }

  } else {

    if(splitValue.length > 1) {
      for (var element in splitValue) {
        if(index >= 1) {
          suffix += "/$element";
        }
        index++;
      }
      var prefixString = replaceAll(suffix, "");
      return [
        prefixString, suffix
      ];
    }

  }

  return [this, "/"];

}