mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-03-29 00:00:33 -04:00
Fix shortenUrl helper to not crash when URL doesn't include any "/".
This commit is contained in:
parent
3a6c3ee65d
commit
8bf872e92e
1 changed files with 3 additions and 2 deletions
|
@ -106,10 +106,11 @@ Handlebars.registerHelper('titledLinkTo', function(name, object) {
|
|||
@for Handlebars
|
||||
**/
|
||||
Handlebars.registerHelper('shortenUrl', function(property, options) {
|
||||
var url;
|
||||
var url, matches;
|
||||
url = Ember.Handlebars.get(this, property, options);
|
||||
// Remove trailing slash if it's a top level URL
|
||||
if (url.match(/\//g).length === 3) {
|
||||
matches = url.match(/\//g);
|
||||
if (matches && matches.length === 3) {
|
||||
url = url.replace(/\/$/, '');
|
||||
}
|
||||
url = url.replace(/^https?:\/\//, '');
|
||||
|
|
Loading…
Add table
Reference in a new issue