Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated dependencies and moved to nanoId #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# mongoose-slug-updater

# Forked Version with updated dependencies

Sophisticated slugifier plugin for Mongoose.

> There is also [PlanZed.org](https://planzed.org/) - awesome cloud mind map app created by the author of mongoose-slug-updater.
Expand Down
12 changes: 6 additions & 6 deletions lib/slug-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const _ = require('deepdash')(require('lodash'));

const getSlug = require('speakingurl');

const shortId = require('shortid');
const { nanoid } = require('nanoid')

module.exports = function plugin(schema, options) {
options = _.merge(
Expand Down Expand Up @@ -334,7 +334,7 @@ async function findSame(
isCounter,
options,
findOne,
permanent
permanent,
// slugsMdfPaths
) {
// console.log(`findSame#${doc.n} ${path}: ${slug}`);
Expand Down Expand Up @@ -573,7 +573,7 @@ async function setSlugs(doc, slugs, options, findOne, cache) {
query,
findOne,
cache,
slug.permanent
slug.permanent,
// slugsMdfPaths
),
);
Expand Down Expand Up @@ -627,7 +627,7 @@ async function makeUniqueCounterSlug(
true,
options,
findOne,
permanent
permanent,
// slugsMdfPaths
);
if (result) {
Expand Down Expand Up @@ -674,9 +674,9 @@ async function makeUniqueShortIdSlug(
) {
// console.log("reuse old random slug",doc[path]);
slug = oldSlug;
} else slug += options.separator + shortId.generate();
} else slug += options.separator + nanoid(11);
} else if (forceShortId) {
slug += options.separator + shortId.generate();
slug += options.separator + nanoid(11);
}
updateUpdCache(cache, path, originalSlug, slug, groups);
// console.log('after cache', cache);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"dependencies": {
"deepdash": "^5.3.5",
"lodash": "^4.17.20",
"shortid": "^2.2.16",
"nanoid": "^3.2.0",
"speakingurl": "^14.0.1"
},
"devDependencies": {
Expand All @@ -73,7 +73,7 @@
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.22.0",
"mocha": "^8.3.0",
"mocha": "^9.2.0",
"mongodb-memory-server": "^6.9.3",
"mongoose": "^5.11.17",
"nodemon": "^2.0.7",
Expand Down