Skip to content

Commit

Permalink
🐛 https image urls if accessed over SSL (#8373)
Browse files Browse the repository at this point in the history
closes #8372

- https image urls if accessed over SSL (fix secure option for images)
  • Loading branch information
sovietspaceship authored and kirrg001 committed May 15, 2017
1 parent 1b965fa commit e066094
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion core/server/utils/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ function urlFor(context, data, absolute) {
urlPath = data.image;
imagePathRe = new RegExp('^' + getSubdir() + '/' + STATIC_IMAGE_URL_PREFIX);
absolute = imagePathRe.test(data.image) ? absolute : false;
secure = data.image.secure;

if (absolute) {
// Remove the sub-directory from the URL because ghostConfig will add it back.
Expand Down
6 changes: 6 additions & 0 deletions core/test/unit/utils/url_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ describe('Url', function () {
testData = {image: '/blog/content/images/my-image4.jpg'};
utils.url.urlFor(testContext, testData).should.equal('/blog/content/images/my-image4.jpg');
utils.url.urlFor(testContext, testData, true).should.equal('http://my-ghost-blog.com/blog/content/images/my-image4.jpg');

// Test case for blogs with optional https -
// they may be configured with http url but the actual connection may be over https (#8373)
configUtils.set({url: 'http://my-ghost-blog.com'});
testData = {image: '/content/images/my-image.jpg', secure: true};
utils.url.urlFor(testContext, testData, true).should.equal('https://my-ghost-blog.com/content/images/my-image.jpg');
});

it('should return a url for a nav item when asked for it', function () {
Expand Down

0 comments on commit e066094

Please sign in to comment.