discourse/app/assets/javascripts/discourse/helpers/shorten-url.js.es6

13 lines
339 B
Text
Raw Normal View History

2014-12-11 14:13:57 -05:00
import registerUnbound from 'discourse/helpers/register-unbound';
registerUnbound('shorten-url', function(url) {
var matches = url.match(/\//g);
if (matches && matches.length === 3) {
url = url.replace(/\/$/, '');
}
url = url.replace(/^https?:\/\//, '');
url = url.replace(/^www\./, '');
return url.substring(0, 80);
});