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:
parent
6292aacedc
commit
1d1f24d3d4
2 changed files with 3 additions and 3 deletions
|
@ -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.
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Add table
Reference in a new issue