mirror of
https://github.com/discourse/discourse.git
synced 2025-01-26 14:27:13 +08:00
13 lines
337 B
JavaScript
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);
|
|
});
|