Not sure if this is better, but can be shortened to just 

`data.url_name = data.content_url.substring(0,30) + (data.content_url.length > 30 ? '...' : '');`