0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

ensure amp works when blog is running in subdirectory (#7353)

closes #7352
- use relative url instead of absolute url for post lookup
- add test that passes w/these changes
This commit is contained in:
Austin Burdine 2016-09-14 06:47:25 -05:00 committed by Hannah Wolfe
parent 03ca49ca5e
commit 78f580763f
3 changed files with 12 additions and 3 deletions

View file

@ -33,7 +33,7 @@ function controller(req, res, next) {
}
function getPostData(req, res, next) {
postLookup(req.originalUrl)
postLookup(res.locals.relativeUrl)
.then(function (result) {
if (result && result.post) {
req.body.post = result.post;

View file

@ -141,10 +141,13 @@ describe('AMP getPostData', function () {
var res, req, postLookupStub, next;
beforeEach(function () {
res = {};
res = {
locals: {
relativeUrl: '/welcome-to-ghost/amp/'
}
};
req = {
originalUrl: '/welcome-to-ghost/amp/',
body: {
post: {}
}

View file

@ -555,6 +555,12 @@ describe('Frontend Routing', function () {
.end(doEnd(done));
});
it('/blog/welcome-to-ghost/amp/ should 200', function (done) {
request.get('/blog/welcome-to-ghost/amp/')
.expect(200)
.end(doEnd(done));
});
it('should uncapitalise correctly with 301 to subdir', function (done) {
request.get('/blog/AAA/')
.expect('Location', '/blog/aaa/')