0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Accept mailto: links

refs #4989

- this allows users to enter mailto and output links via the navigation UI
- the navigation validation/cleanup needs a bit of a refactor to handle other kinds or URI, so leaving #4989 open for now
This commit is contained in:
Hannah Wolfe 2015-03-08 18:27:00 +00:00
parent f25c253096
commit b216677161
3 changed files with 4 additions and 3 deletions

View file

@ -20,7 +20,7 @@ var NavItemUrlInputComponent = Ember.TextField.extend({
}),
isRelative: Ember.computed('value', function () {
return !validator.isURL(this.get('value'));
return !validator.isURL(this.get('value')) && this.get('value').indexOf('mailto:') !== 0;
}),
didInsertElement: function () {
@ -80,6 +80,7 @@ var NavItemUrlInputComponent = Ember.TextField.extend({
var url = this.get('value'),
baseUrl = this.get('baseUrl');
// if we have a relative url, create the absolute url to be displayed in the input
if (this.get('isRelative')) {
this.set('value', joinUrlParts(baseUrl, url));
}

View file

@ -132,7 +132,7 @@ NavigationController = Ember.Controller.extend({
if (url[url.length - 1] !== '/') {
url += '/';
}
} else if (!validator.isURL(url) && url !== '' && url[0] !== '/') {
} else if (!validator.isURL(url) && url !== '' && url[0] !== '/' && url.indexOf('mailto:') !== 0) {
url = '/' + url;
}

View file

@ -170,7 +170,7 @@ function urlFor(context, data, absolute) {
}
// This url already has a protocol so is likely an external url to be returned
if (urlPath && urlPath.indexOf('://') !== -1) {
if (urlPath && (urlPath.indexOf('://') !== -1 || urlPath.indexOf('mailto:') === 0)) {
return urlPath;
}