mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Merge pull request #5581 from halfdan/fix/5561
Fix urlFor to preserve mailto:
This commit is contained in:
commit
fffa2a7958
2 changed files with 7 additions and 1 deletions
|
@ -190,7 +190,9 @@ function urlFor(context, data, absolute) {
|
||||||
urlPath = data.nav.url;
|
urlPath = data.nav.url;
|
||||||
baseUrl = getBaseUrl(secure);
|
baseUrl = getBaseUrl(secure);
|
||||||
hostname = baseUrl.split('//')[1] + ghostConfig.paths.subdir;
|
hostname = baseUrl.split('//')[1] + ghostConfig.paths.subdir;
|
||||||
if (urlPath.indexOf(hostname) > -1 && urlPath.indexOf('.' + hostname) === -1) {
|
if (urlPath.indexOf(hostname) > -1
|
||||||
|
&& urlPath.indexOf('.' + hostname) === -1
|
||||||
|
&& urlPath.indexOf('mailto:') !== 0) {
|
||||||
// make link relative to account for possible
|
// make link relative to account for possible
|
||||||
// mismatch in http/https etc, force absolute
|
// mismatch in http/https etc, force absolute
|
||||||
// do not do so if link is a subdomain of blog url
|
// do not do so if link is a subdomain of blog url
|
||||||
|
|
|
@ -382,6 +382,10 @@ describe('Config', function () {
|
||||||
config.set({url: 'http://my-ghost-blog.com/blog'});
|
config.set({url: 'http://my-ghost-blog.com/blog'});
|
||||||
testData = {nav: {url: 'http://my-ghost-blog.com/blog/short-and-sweet/'}};
|
testData = {nav: {url: 'http://my-ghost-blog.com/blog/short-and-sweet/'}};
|
||||||
config.urlFor(testContext, testData).should.equal('http://my-ghost-blog.com/blog/short-and-sweet/');
|
config.urlFor(testContext, testData).should.equal('http://my-ghost-blog.com/blog/short-and-sweet/');
|
||||||
|
|
||||||
|
config.set({url: 'http://my-ghost-blog.com/'});
|
||||||
|
testData = {nav: {url: 'mailto:marshmallow@my-ghost-blog.com'}};
|
||||||
|
config.urlFor(testContext, testData).should.equal('mailto:marshmallow@my-ghost-blog.com');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return other known paths when requested', function () {
|
it('should return other known paths when requested', function () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue