Ben, I think it's fine to just remove up to the first dot as you did. So simply change it to

    new uri.split('/').last.split('.').head

Same in the one below. I just think this is slightly easier to understand than making a file from a potentially-non-file:// URI.