Skip to content

Commit e9b006c

Browse files
committed
Updated slugification strategy
1 parent 97d1abd commit e9b006c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/simple-slugify.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
const crypto = require('crypto');
44

5-
const regex = /[&/\\#,+()$~%.'":*?!<>{} ]/g;
5+
const regex = /[&/\\#,+()$~%.'":*?!<>{}]/g;
66

77
module.exports = function (schema) {
88
schema.pre(['save'], async function (next) {
99
const { source } = schema.tree.slug;
1010

11-
let slug = this[source].toString().toLowerCase().trim().replace(regex, '-');
11+
let slug = this[source].toString().toLowerCase().trim().replaceAll(' ', '-').replace(regex, '');
1212

1313
try {
1414
slug = (await this.model(this.constructor.modelName).exists({ slug }))

0 commit comments

Comments
 (0)