Skip to content

Commit

Permalink
ensure amp works when blog is running in subdirectory (#7353)
Browse files Browse the repository at this point in the history
closes #7352
- use relative url instead of absolute url for post lookup
- add test that passes w/these changes
  • Loading branch information
acburdine authored and ErisDS committed Sep 14, 2016
1 parent 03ca49c commit 78f5807
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/server/apps/amp/lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions core/server/apps/amp/tests/router_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
}
Expand Down
6 changes: 6 additions & 0 deletions core/test/functional/routes/frontend_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/')
Expand Down

0 comments on commit 78f5807

Please sign in to comment.