Skip to content

Commit 11d38fa

Browse files
committed
Fixed core bug with set and the increments not taking into account config.slugOptions
1 parent c95c2e7 commit 11d38fa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const slug = require('speakingurl');
66

77
const getUniqueSlug = async (config, constructor, _id, str, i = 0) => {
88
if (s.isBlank(str)) throw new Error('The `str` argument was missing');
9-
const search = i === 0 ? str : `${str}-${i}`;
9+
const search = i === 0 ? str : config.slug(`${str}-${i}`, config.slugOptions);
1010
const query = { _id: { $ne: _id } };
1111
query[config.slugField] = search;
1212
if (config.paranoid === 'hidden') query.hidden = { $ne: null };
@@ -38,7 +38,7 @@ const mongooseSlugPlugin = (schema, config = {}) => {
3838
unique: true,
3939
required: true,
4040
trim: true,
41-
set: config.slug,
41+
set: val => config.slug(val, config.slugOptions),
4242
validate: {
4343
isAsync: true,
4444
validator(val, fn) {

0 commit comments

Comments
 (0)