0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Properly server shared files

refs #3992
- Don't use path.join for URLs
- Cache robots.txt for 1h instead of 1y
This commit is contained in:
Fabian Becker 2014-09-25 10:00:51 +00:00
parent 6292aacedc
commit 1d1f24d3d4
2 changed files with 3 additions and 3 deletions

View file

@ -206,7 +206,7 @@ function serveSharedFile(file, type, maxAge) {
filePath = path.join(config.paths.corePath, 'shared', file);
return function serveSharedFile(req, res, next) {
if (req.url === path.join('/', file)) {
if (req.url === '/' + file) {
if (content) {
res.writeHead(200, content.headers);
res.end(content.body);
@ -290,7 +290,7 @@ setupMiddleware = function (blogAppInstance, adminApp) {
blogApp.use(middleware.staticTheme());
// Serve robots.txt if not found in theme
blogApp.use(serveSharedFile('robots.txt', 'text/plain', utils.ONE_YEAR_S));
blogApp.use(serveSharedFile('robots.txt', 'text/plain', utils.ONE_HOUR_S));
// Add in all trailing slashes, properly include the subdir path
// in the redirect.

View file

@ -452,7 +452,7 @@ describe('Frontend Routing', function () {
it('should retrieve default robots.txt', function (done) {
request.get('/robots.txt')
.expect('Cache-Control', testUtils.cacheRules.year)
.expect('Cache-Control', testUtils.cacheRules.hour)
.expect('ETag', /[0-9a-f]{32}/i)
.expect(200)
.end(doEnd(done));