mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 23:57:32 +00:00
Fix create slug bug
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
d27e901e72
commit
a127f35018
@ -19,6 +19,11 @@ const mergeParams = (refParams, params) => {
|
||||
|
||||
const getDeleteRedirectionLink = (links, slug, rawQuery) => {
|
||||
const matchingLink = links.find(({ destination }) => destination.includes(slug));
|
||||
|
||||
if (!matchingLink) {
|
||||
return { destination: '/', search: '' };
|
||||
}
|
||||
|
||||
const { search } = matchingLink;
|
||||
const searchQueryParams = parse(search);
|
||||
const currentQueryParams = parse(rawQuery.substring(1));
|
||||
|
||||
@ -2,6 +2,22 @@ import getDeleteRedirectionLink, { mergeParams } from '../getDeleteRedirectionLi
|
||||
|
||||
describe('CONTENT MANAGER | Containers | CollectionTypeFormWrapper | utils ', () => {
|
||||
describe('getDeleteRedirectionLink', () => {
|
||||
it('should return an when no links is matching the slug', () => {
|
||||
const links = [
|
||||
{
|
||||
destination: '/cm/foo',
|
||||
search: 'page=1&pageSize=10',
|
||||
},
|
||||
{
|
||||
destination: '/cm/bar',
|
||||
search: 'page=1&pageSize=10',
|
||||
},
|
||||
];
|
||||
const slug = 'create';
|
||||
const result = getDeleteRedirectionLink(links, slug, '');
|
||||
|
||||
expect(result).toEqual({ destination: '/', search: '' });
|
||||
});
|
||||
it('should not mutate the link when the rawQuery is empty', () => {
|
||||
const links = [
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user