mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
🐛 fix double slashes in URLs (#506)
no issue - update `config` service normalise blogUrl to non-trailing slash to match previous API behaviour - fixes double slashes appearing in places around the app - fixes "Redirect URI Mismatch" errors when using Ghost OAuth due to the double slashes
This commit is contained in:
parent
66f7bad47b
commit
ec760ca2f6
@ -17,6 +17,10 @@ export default Service.extend(_ProxyMixin, {
|
||||
let configUrl = this.get('ghostPaths.url').api('configuration');
|
||||
|
||||
return this.get('ajax').request(configUrl).then((config) => {
|
||||
// normalize blogUrl to non-trailing-slash
|
||||
let [{blogUrl}] = config.configuration;
|
||||
config.configuration[0].blogUrl = blogUrl.replace(/\/$/, '');
|
||||
|
||||
this.set('content', config.configuration[0]);
|
||||
});
|
||||
},
|
||||
|
@ -2,6 +2,7 @@ import {expect} from 'chai';
|
||||
import {describe, it} from 'mocha';
|
||||
import {setupTest} from 'ember-mocha';
|
||||
import Pretender from 'pretender';
|
||||
import wait from 'ember-test-helpers/wait';
|
||||
|
||||
function stubAvailableTimezonesEndpoint(server) {
|
||||
server.get('/ghost/api/v0.1/configuration/timezones', function () {
|
||||
@ -54,4 +55,41 @@ describe('Integration: Service: config', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('normalizes blogUrl to non-trailing-slash', function (done) {
|
||||
let stubBlogUrl = function stubBlogUrl(blogUrl) {
|
||||
server.get('/ghost/api/v0.1/configuration/', function () {
|
||||
return [
|
||||
200,
|
||||
{'Content-Type': 'application/json'},
|
||||
JSON.stringify({
|
||||
configuration: [{
|
||||
blogUrl
|
||||
}]
|
||||
})
|
||||
];
|
||||
});
|
||||
};
|
||||
let service = this.subject();
|
||||
|
||||
stubBlogUrl('http://localhost:2368/');
|
||||
|
||||
service.fetch().then(() => {
|
||||
expect(
|
||||
service.get('blogUrl'), 'trailing-slash'
|
||||
).to.equal('http://localhost:2368');
|
||||
});
|
||||
|
||||
wait().then(() => {
|
||||
stubBlogUrl('http://localhost:2368');
|
||||
|
||||
service.fetch().then(() => {
|
||||
expect(
|
||||
service.get('blogUrl'), 'non-trailing-slash'
|
||||
).to.equal('http://localhost:2368');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user