Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:issue on do not validate locale if not creating for all locales #19799

Merged
7 changes: 6 additions & 1 deletion packages/plugins/i18n/server/src/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@ export default ({ strapi }: { strapi: Strapi }) => {
const isUrlForCreation = (url: string) => {
if (!url) return false;

// Remove any query params
// /content-manager/collection-types/api::category.category/?locale=en
const path = url.split('?')[0];

// Split path and remove empty strings
// [ 'content-manager', 'collection-types', 'api::category.category' ]
const splitUrl = url.split('/').filter(Boolean);
const splitUrl = path.split('/').filter(Boolean);

// Get the last element of the array
// api::category.category / 1 / publish

const model = splitUrl[splitUrl.length - 1];

// If the model contains :: it means it's a uid
Expand Down