Should probably use a combination of Ruby's URI and File APIs here.