I always thought the first, with ś, was correct, and the second was just an orthographic error.  Then I saw "-koṣa" on the title page of Ingalls's Subhāṣitaratnakoṣa.  He must have thought about this.

So which is "right" and why?

Best,
Dominik

PS I haven't even done elementary due diligence on this question, beyond MW.