getFormat function

String getFormat(
  1. String url
)

Get the file format from a URL

Implementation

String getFormat(String url) {
  int dotCharacterIndex;

  if (url.startsWith('#')) {
    dotCharacterIndex = url.lastIndexOf('=');
  } else {
    dotCharacterIndex = url.lastIndexOf('.');
  }

  if (dotCharacterIndex >= 0) {
    return url.substring(dotCharacterIndex + 1);
  } else {
    return "";
  }
}