b29852b012
closes: https://github.com/TryGhost/Toolbox/issues/324 refs: https://github.com/TryGhost/Ghost/issues/14446 - Currently, if url is configured to http but a request is marked secure, Ghost will handle upgrading all internal URLs to https so that there are no mixed content warnings - From 5.0 that feature is going away, in favour of strictly honouring the configured URL - Ghost will serve URLs exactly as configured and won't upgrade http to https anymore - This use case was common when Ghost was first built, but in 2022 the web is mostly https. - The code needed to support the feature creates a lot of additional complexity & maintenance overhead, so removing this gives us space to do more cool and useful stuff in 2022
85 lines
2.5 KiB
JavaScript
85 lines
2.5 KiB
JavaScript
const should = require('should');
|
|
const sinon = require('sinon');
|
|
const ObjectId = require('bson-objectid');
|
|
const urlService = require('../../../../core/server/services/url');
|
|
const getAuthorUrl = require('../../../../core/frontend/meta/author-url');
|
|
|
|
describe('getAuthorUrl', function () {
|
|
beforeEach(function () {
|
|
sinon.stub(urlService, 'getUrlByResourceId');
|
|
});
|
|
|
|
afterEach(function () {
|
|
sinon.restore();
|
|
});
|
|
|
|
it('should return author url if context contains primary author', function () {
|
|
const post = {
|
|
primary_author: {
|
|
id: ObjectId().toHexString(),
|
|
slug: 'test-author'
|
|
}
|
|
};
|
|
|
|
urlService.getUrlByResourceId.withArgs(post.primary_author.id, {absolute: undefined, withSubdirectory: true})
|
|
.returns('author url');
|
|
|
|
should.exist(getAuthorUrl({
|
|
context: ['post'],
|
|
post: post
|
|
}));
|
|
});
|
|
|
|
it('should return absolute author url if context contains primary author', function () {
|
|
const post = {
|
|
primary_author: {
|
|
id: ObjectId().toHexString(),
|
|
slug: 'test-author'
|
|
}
|
|
};
|
|
|
|
urlService.getUrlByResourceId.withArgs(post.primary_author.id, {absolute: true, withSubdirectory: true})
|
|
.returns('absolute author url');
|
|
|
|
should.exist(getAuthorUrl({
|
|
context: ['post'],
|
|
post: post
|
|
}, true));
|
|
});
|
|
|
|
it('should return author url for AMP if context contains primary author', function () {
|
|
const post = {
|
|
primary_author: {
|
|
id: ObjectId().toHexString(),
|
|
slug: 'test-author'
|
|
}
|
|
};
|
|
|
|
urlService.getUrlByResourceId.withArgs(post.primary_author.id, {absolute: undefined, withSubdirectory: true})
|
|
.returns('author url');
|
|
|
|
should.exist(getAuthorUrl({
|
|
context: ['amp', 'post'],
|
|
post: post
|
|
}));
|
|
});
|
|
|
|
it('should return author url if data contains author', function () {
|
|
const author = {
|
|
id: ObjectId().toHexString(),
|
|
slug: 'test-author'
|
|
};
|
|
|
|
urlService.getUrlByResourceId.withArgs(author.id, {absolute: undefined, withSubdirectory: true})
|
|
.returns('author url');
|
|
|
|
should.exist(getAuthorUrl({
|
|
author: author
|
|
}));
|
|
});
|
|
|
|
it('should return null if no author on data or context', function () {
|
|
should.not.exist(getAuthorUrl({}, true));
|
|
});
|
|
});
|