This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/helpers/shorten-url.js.es6

13 lines
337 B
JavaScript

import { registerUnbound } from 'discourse-common/lib/helpers';
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);
});