Auto detect extension