Skip to content

Commit

Permalink
fix:issue on do not validate locale if not creating for all locales (#…
Browse files Browse the repository at this point in the history
…19799)

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

* Update register.ts

* run prettier

* change the syntax to handle more cases
  • Loading branch information
binar1 committed Mar 27, 2024
1 parent a4bd82c commit 4fa6d95
Showing 1 changed file with 6 additions and 1 deletion.
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

0 comments on commit 4fa6d95

Please sign in to comment.