strapi-plugin-slugify icon indicating copy to clipboard operation
strapi-plugin-slugify copied to clipboard

slugifyWithCount is non persistent between project restarts

Open selected-pixel-jameson opened this issue 2 years ago • 4 comments

I don't want duplicate slugs to be allowed in any capacity. However, I'm noticing that when the first duplicate slug is generated it doesn't append the correct -1 to it. For example:

Title = "Test" Slug = "test"

Title = "Test" ( In this case the slug should be generated as test-1, but it's not.) Slug = "test"

Title = "Test" ( In this case the slug should come out as test-2) Slug = "test-2"

So for some reason the first time a duplicate slug is generated the count is not getting attached to the generated slug. However, the next time a duplicate slug is generated the count is attached correctly.

These are the setting I have `` slugify: { enabled: true, config: { slugifyWithCount: true, contentTypes: { jam: { field: 'slug', references: 'title', }, track: { field: 'slug', references: 'title' }, }, }, },


I'm using the latest version `2.3.1`

selected-pixel-jameson avatar Nov 03 '22 17:11 selected-pixel-jameson

This seems to be an issue with the slug not being normalized. The example provided above would actually work correctly. What would not work correctly would be.

Title = "test" Slug = "test"

Title = "Test" ( In this case the slug should be generated as test-1, but it's not.) Slug = "test"

Title = "test" ( In this case the slug should come out as test-2) Slug = "test-2"

selected-pixel-jameson avatar Nov 03 '22 21:11 selected-pixel-jameson

Well this is very strange now. I only can replicate this on my development and production environments. It does not seem to happen on my local environment. I know that all the versions are the same across these environments. I'm at a lose as to why this would be happening.

selected-pixel-jameson avatar Nov 04 '22 01:11 selected-pixel-jameson

WOW! The count for any given slug is stored using a constant in the programming and is not calculated off the actual number of fields in the database that have a title with the slug. These means every time you restart your server the number will get reset, thus you will never have truly unique slugs. If you were running a scalable environment this would be hosed from the get go.

selected-pixel-jameson avatar Nov 04 '22 01:11 selected-pixel-jameson

I cannot replicate the original reported behaviour of different casing resulting in a different count.

In regards to non persisten slug count that will be fixed by #82

ComfortablyCoding avatar Nov 06 '22 06:11 ComfortablyCoding

Fixed in v2.3.2

ComfortablyCoding avatar Dec 08 '22 02:12 ComfortablyCoding