From b2166771615878d6b8c813efb373e0095dd0572c Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Sun, 8 Mar 2015 18:27:00 +0000 Subject: [PATCH] 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 --- core/client/components/gh-navitem-url-input.js | 3 ++- core/client/controllers/settings/navigation.js | 2 +- core/server/config/url.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/client/components/gh-navitem-url-input.js b/core/client/components/gh-navitem-url-input.js index 589e07f06b..7cdb15ea04 100644 --- a/core/client/components/gh-navitem-url-input.js +++ b/core/client/components/gh-navitem-url-input.js @@ -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)); } diff --git a/core/client/controllers/settings/navigation.js b/core/client/controllers/settings/navigation.js index ef798f83c5..907f3b80b9 100644 --- a/core/client/controllers/settings/navigation.js +++ b/core/client/controllers/settings/navigation.js @@ -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; } diff --git a/core/server/config/url.js b/core/server/config/url.js index fb85a7d78f..af33f108d2 100644 --- a/core/server/config/url.js +++ b/core/server/config/url.js @@ -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; }