Skip to content

Commit fca252a

Browse files
authored
Merge pull request #217 from pluginpal/feature/fix-uniqueness
fix: incorrect duplication prevention for content types without inter…
2 parents 34a87ea + 36bf8d3 commit fca252a

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

.changeset/easy-comics-fail.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"strapi-plugin-webtools": patch
3+
---
4+
5+
Fix incorrect duplication prevention for content types without internationalization

packages/core/server/middlewares/prevent-duplicate-urls.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,15 @@ const preventDuplicateUrlsMiddleware: Modules.Documents.Middleware.Middleware =
1818
const params = context.params as Modules.Documents.ServiceParams<'plugin::webtools.url-alias'>['create' | 'update' | 'clone'] & { documentId: string };
1919

2020
if (params.data.url_path) {
21-
params.data.url_path = await getPluginService('url-alias').makeUniquePath(
22-
params.data.url_path,
23-
action !== 'clone' && [
24-
{
25-
documentId: params.documentId,
26-
},
27-
{
28-
locale: params.locale,
29-
},
30-
],
31-
);
21+
const excludeFilters: { [key: string]: any }[] = [];
22+
23+
excludeFilters.push({ documentId: params.documentId });
24+
25+
if (params.locale) {
26+
excludeFilters.push({ locale: params.locale });
27+
}
28+
29+
params.data.url_path = await getPluginService('url-alias').makeUniquePath(params.data.url_path, action !== 'clone' && excludeFilters);
3230
}
3331

3432
return next();

0 commit comments

Comments
 (0)