Why are you splitting and getting the last component here? `File.extname` should work regardless of it being a full path.