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

Switched post routing to uuid instead of slug

refs https://github.com/TryGhost/Team/issues/990

- Relying on uuid instead of slug makes the posts less discoverable and partially soves discoverability through overriden robots.txt files
This commit is contained in:
Naz 2021-08-19 12:27:45 +04:00
parent 2f2fe16944
commit 937d9e58d1
4 changed files with 11 additions and 6 deletions

View file

@ -26,7 +26,7 @@ class EmailRouter extends ParentRouter {
this.router().use(this._prepareContext.bind(this));
// REGISTER: actual email route
this.mountRoute(urlUtils.urlJoin(this.route.value, ':slug', ':options?'), controllers.email);
this.mountRoute(urlUtils.urlJoin(this.route.value, ':uuid', ':options?'), controllers.email);
}
/**

View file

@ -17,7 +17,7 @@ module.exports = function emailPostController(req, res, next) {
const api = require('../../proxy').api[res.locals.apiVersion];
const params = {
slug: req.params.slug,
uuid: req.params.uuid,
include: 'authors,tags',
context: {
member: res.locals.member

View file

@ -12,7 +12,7 @@ module.exports = {
'include'
],
data: [
'slug'
'uuid'
],
validation: {
options: {
@ -21,7 +21,7 @@ module.exports = {
}
},
data: {
slug: {
uuid: {
required: true
}
}

View file

@ -56,7 +56,7 @@ describe('Frontend Routing: Email Routes', function () {
});
it('should display email_only post', async function () {
const res = await request.get(`/email/${emailPosts[0].get('slug')}/`)
const res = await request.get(`/email/${emailPosts[0].get('uuid')}/`)
.expect('Content-Type', /html/)
.expect(200);
@ -71,7 +71,12 @@ describe('Frontend Routing: Email Routes', function () {
});
it('404s for draft email only post', function () {
return request.get(`/email/${emailPosts[1].get('slug')}/`)
return request.get(`/email/${emailPosts[1].get('uuid')}/`)
.expect(404);
});
it('404s known slug', function () {
return request.get(`/email/${emailPosts[0].get('slug')}/`)
.expect(404);
});