mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
🐛 Fix double slash in scheduling API URL (#8574)
closes #8568 - use our `urlJoin` util to concatenate the URL (not the query part of it, as this is not supported in `urlJoin`) and to prevent possible missing or double slashes, as `config.apiUrl` could be with or without trailing slash
This commit is contained in:
parent
57f8367cdf
commit
5bc5eca315
2 changed files with 4 additions and 2 deletions
|
@ -5,6 +5,7 @@ var Promise = require('bluebird'),
|
||||||
errors = require(__dirname + '/../../../errors'),
|
errors = require(__dirname + '/../../../errors'),
|
||||||
models = require(__dirname + '/../../../models'),
|
models = require(__dirname + '/../../../models'),
|
||||||
schedules = require(__dirname + '/../../../api/schedules'),
|
schedules = require(__dirname + '/../../../api/schedules'),
|
||||||
|
utils = require(__dirname + '/../../../utils'),
|
||||||
_private = {};
|
_private = {};
|
||||||
|
|
||||||
_private.normalize = function normalize(options) {
|
_private.normalize = function normalize(options) {
|
||||||
|
@ -14,7 +15,7 @@ _private.normalize = function normalize(options) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
time: moment(object.get('published_at')).valueOf(),
|
time: moment(object.get('published_at')).valueOf(),
|
||||||
url: apiUrl + '/schedules/posts/' + object.get('id') + '?client_id=' + client.get('slug') + '&client_secret=' + client.get('secret'),
|
url: utils.url.urlJoin(apiUrl, 'schedules', 'posts', object.get('id')) + '?client_id=' + client.get('slug') + '&client_secret=' + client.get('secret'),
|
||||||
extra: {
|
extra: {
|
||||||
httpMethod: 'PUT',
|
httpMethod: 'PUT',
|
||||||
oldTime: object.updated('published_at') ? moment(object.updated('published_at')).valueOf() : null
|
oldTime: object.updated('published_at') ? moment(object.updated('published_at')).valueOf() : null
|
||||||
|
|
|
@ -11,6 +11,7 @@ var should = require('should'),
|
||||||
schedulingUtils = require(config.get('paths').corePath + '/server/adapters/scheduling/utils'),
|
schedulingUtils = require(config.get('paths').corePath + '/server/adapters/scheduling/utils'),
|
||||||
SchedulingDefault = require(config.get('paths').corePath + '/server/adapters/scheduling/SchedulingDefault'),
|
SchedulingDefault = require(config.get('paths').corePath + '/server/adapters/scheduling/SchedulingDefault'),
|
||||||
postScheduling = require(config.get('paths').corePath + '/server/adapters/scheduling/post-scheduling'),
|
postScheduling = require(config.get('paths').corePath + '/server/adapters/scheduling/post-scheduling'),
|
||||||
|
generalUtils = require(__dirname + '/../../../../../server/utils'),
|
||||||
|
|
||||||
sandbox = sinon.sandbox.create();
|
sandbox = sinon.sandbox.create();
|
||||||
|
|
||||||
|
@ -69,7 +70,7 @@ describe('Scheduling: Post Scheduling', function () {
|
||||||
|
|
||||||
scope.adapter.schedule.calledWith({
|
scope.adapter.schedule.calledWith({
|
||||||
time: moment(scope.post.get('published_at')).valueOf(),
|
time: moment(scope.post.get('published_at')).valueOf(),
|
||||||
url: scope.apiUrl + '/schedules/posts/' + scope.post.get('id') + '?client_id=' + scope.client.get('slug') + '&client_secret=' + scope.client.get('secret'),
|
url: generalUtils.url.urlJoin(scope.apiUrl, 'schedules', 'posts', scope.post.get('id')) + '?client_id=' + scope.client.get('slug') + '&client_secret=' + scope.client.get('secret'),
|
||||||
extra: {
|
extra: {
|
||||||
httpMethod: 'PUT',
|
httpMethod: 'PUT',
|
||||||
oldTime: null
|
oldTime: null
|
||||||
|
|
Loading…
Reference in a new issue