mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-12 00:31:48 -05:00
12 lines
339 B
JavaScript
12 lines
339 B
JavaScript
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);
|
|
});
|