I wrote this to convert any string of text into a pretty url, mostly for Wordpress, and given the reslug plugin is problematic with latest Wordpress iterations, I wrote my own quick implementation of sanitize_text_field() in jquery