Resonances of narrow one-dimensional cavities