Revert "🐛 Fixed frontend routing prioritizing collections over built in routes (#20765)"
refs https://app.incident.io/ghost/incidents/102
- this reverts commit c0471f0c28
This commit is contained in:
parent
af0338b504
commit
2757ef70fa
@ -126,13 +126,6 @@ class RouterManager {
|
|||||||
this.registry.setRouter(staticRoutesRouter.identifier, staticRoutesRouter);
|
this.registry.setRouter(staticRoutesRouter.identifier, staticRoutesRouter);
|
||||||
});
|
});
|
||||||
|
|
||||||
_.each(routerSettings.taxonomies, (value, key) => {
|
|
||||||
const taxonomyRouter = new TaxonomyRouter(key, value, RESOURCE_CONFIG, this.routerCreated.bind(this));
|
|
||||||
this.siteRouter.mountRouter(taxonomyRouter.router());
|
|
||||||
|
|
||||||
this.registry.setRouter(taxonomyRouter.identifier, taxonomyRouter);
|
|
||||||
});
|
|
||||||
|
|
||||||
_.each(routerSettings.collections, (value, key) => {
|
_.each(routerSettings.collections, (value, key) => {
|
||||||
const collectionRouter = new CollectionRouter(key, value, RESOURCE_CONFIG, this.routerCreated.bind(this));
|
const collectionRouter = new CollectionRouter(key, value, RESOURCE_CONFIG, this.routerCreated.bind(this));
|
||||||
this.siteRouter.mountRouter(collectionRouter.router());
|
this.siteRouter.mountRouter(collectionRouter.router());
|
||||||
@ -144,6 +137,13 @@ class RouterManager {
|
|||||||
|
|
||||||
this.registry.setRouter('staticPagesRouter', staticPagesRouter);
|
this.registry.setRouter('staticPagesRouter', staticPagesRouter);
|
||||||
|
|
||||||
|
_.each(routerSettings.taxonomies, (value, key) => {
|
||||||
|
const taxonomyRouter = new TaxonomyRouter(key, value, RESOURCE_CONFIG, this.routerCreated.bind(this));
|
||||||
|
this.siteRouter.mountRouter(taxonomyRouter.router());
|
||||||
|
|
||||||
|
this.registry.setRouter(taxonomyRouter.identifier, taxonomyRouter);
|
||||||
|
});
|
||||||
|
|
||||||
const appRouter = new ParentRouter('AppsRouter');
|
const appRouter = new ParentRouter('AppsRouter');
|
||||||
this.siteRouter.mountRouter(appRouter.router());
|
this.siteRouter.mountRouter(appRouter.router());
|
||||||
|
|
||||||
|
@ -80,36 +80,3 @@ describe('Custom Frontend routing', function () {
|
|||||||
.expect(assertCorrectFrontendHeaders);
|
.expect(assertCorrectFrontendHeaders);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Custom frontend routing - edge cases', function () {
|
|
||||||
let request;
|
|
||||||
|
|
||||||
before(async function () {
|
|
||||||
const routesFilePath = path.join(configUtils.config.get('paths:appRoot'), 'test/utils/fixtures/settings/edgecaseroutes.yaml');
|
|
||||||
await configUtils.restore();
|
|
||||||
await testUtils.stopGhost();
|
|
||||||
|
|
||||||
await testUtils.startGhost({
|
|
||||||
forceStart: true,
|
|
||||||
routesFilePath,
|
|
||||||
subdir: false
|
|
||||||
});
|
|
||||||
|
|
||||||
request = supertest.agent(configUtils.config.get('url'));
|
|
||||||
});
|
|
||||||
|
|
||||||
after(async function () {
|
|
||||||
await testUtils.stopGhost();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should prioritize taxonomies over collections', async function () {
|
|
||||||
// Create a tag and a post with the same slug
|
|
||||||
const slug = 'cheese';
|
|
||||||
await testUtils.createTag({tag: {slug}});
|
|
||||||
await testUtils.createPost({post: {tags: [{slug}], slug}});
|
|
||||||
|
|
||||||
// Test that the tag route takes precedence
|
|
||||||
await request.get(`/tag/${slug}/`)
|
|
||||||
.expect(200);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
routes:
|
|
||||||
|
|
||||||
collections:
|
|
||||||
/:
|
|
||||||
permalink: /{primary_tag}/{slug}/
|
|
||||||
template: index
|
|
||||||
|
|
||||||
taxonomies:
|
|
||||||
tag: /tag/{slug}/
|
|
||||||
author: /author/{slug}/
|
|
@ -79,12 +79,6 @@ const createPost = function createPost(options) {
|
|||||||
return models.Post.add(post, context.internal);
|
return models.Post.add(post, context.internal);
|
||||||
};
|
};
|
||||||
|
|
||||||
const createTag = function createTag(options) {
|
|
||||||
const tag = DataGenerator.forKnex.createTag(options.tag);
|
|
||||||
|
|
||||||
return models.Tag.add(tag, context.internal);
|
|
||||||
};
|
|
||||||
|
|
||||||
const createEmail = function createEmail(options) {
|
const createEmail = function createEmail(options) {
|
||||||
const email = DataGenerator.forKnex.createEmail(options.email);
|
const email = DataGenerator.forKnex.createEmail(options.email);
|
||||||
return models.Email.add(email, context.internal);
|
return models.Email.add(email, context.internal);
|
||||||
@ -109,7 +103,6 @@ module.exports = {
|
|||||||
setup: setup,
|
setup: setup,
|
||||||
createUser: createUser,
|
createUser: createUser,
|
||||||
createPost: createPost,
|
createPost: createPost,
|
||||||
createTag: createTag,
|
|
||||||
createEmailedPost,
|
createEmailedPost,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user