module Asciidoctor::Helpers

def extname path, fallback = ''

def extname path, fallback = ''
  if (last_dot_idx = path.rindex '.')
    (path.index '/', last_dot_idx) || (path.index ::File::ALT_SEPARATOR, last_dot_idx) ? fallback : (path.slice last_dot_idx, path.length)
  else
    fallback
  end
end