Get file name with extension and get only extension
You are doing too much work manually. It's so much easier and more powerful to use pattern matching.

The two functions can be written as one-liners:

function GetFileName(url)
  return url:match("^.+/(.+)$")
end

function GetFileExtension(url)
  return url:match("^.+(%..+)$")
end


In the patterns, .+ matches one or more any characters as much as possible (greedy). / matches itself, %. matches the dot .. ^ and $ are the anchors for beginning and ending of a string respectively.