mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 08:14:01 +08:00
12 lines
355 B
JavaScript
12 lines
355 B
JavaScript
Handlebars.registerHelper('shorten-url', function(property, options) {
|
|
var url = Ember.Handlebars.get(this, property, options),
|
|
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);
|
|
});
|