Skip to content
This repository was archived by the owner on Sep 16, 2025. It is now read-only.

Commit f1ff933

Browse files
refactor(slugification): merge slug function into one with count option flag
1 parent 99e6334 commit f1ff933

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

server/utils/slugification.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
'use strict';
22

3+
const _ = require('lodash');
34
const slugify = require('@sindresorhus/slugify');
45
const slugifyWithCount = slugify.counter();
56

6-
const toSlug = (string, options) => slugify(string, options);
7-
const toSlugWithCount = (string, options) => slugifyWithCount(string, options);
7+
const toSlug = (string, options) => {
8+
if (options.slugifyWithCount) {
9+
_.omit(options, 'slugifyWithCount');
10+
return slugifyWithCount(string, options);
11+
}
12+
13+
return slugify(string, options);
14+
};
815

916
module.exports = {
1017
toSlug,
11-
toSlugWithCount,
1218
};

0 commit comments

Comments
 (0)