Merge pull request #1909 from codedinc/shortenUrl-fix

Fix shortenUrl helper to not crash when URL doesn't include any "/".
This commit is contained in:
Régis Hanol 2014-02-06 16:35:11 +01:00
commit 9b3740a7c6

View file

@ -112,10 +112,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?:\/\//, '');