
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
slug-wizard
Advanced tools
slug-wizard is a lightweight, dependency-free NPM package that converts text into a URL-friendly slug. It also ensures uniqueness by checking against an existing list of slugs and appending a number if necessary.
Café → cafe).Create unique, SEO-friendly, and customizable slugs for your applications.
-, _, ., or anything else.&, +, @.npm install slug-wizard
import { createSlug } from 'slug-wizard';
// Default (- separator, lowercase)
console.log(createSlug("Hello World!")); // hello-world
// Customizable
console.log(createSlug("Fruit & Veggies", { separator: '_', stopWords: ['and'] }));
// fruit_veggies
| Option | Default | Description |
|---|---|---|
separator | '-' | Word separator character |
lowercase | true | Convert to lowercase |
maxLength | Infinity | Max length (word-safe) |
stopWords | [] | Words to remove |
import { generateUniqueSlug } from 'slug-wizard';
const existing = ['my-post', 'my-post-1'];
// With counter (default)
console.log(generateUniqueSlug("My Post", { existingSlugs: existing }));
// my-post-2
// With random suffix
console.log(generateUniqueSlug("My Post", { existingSlugs: existing, randomSuffix: true }));
// my-post-x7f2
const slug = await generateUniqueSlug("Premium Product", {
checkCallback: async (val) => {
const exists = await db.products.findFirst({ where: { slug: val } });
return !!exists;
}
});
createSlug(text: string): stringConverts a given text into a slug by:
-generateUniqueSlug(text: string, existingSlugs: string[]): stringConverts text into a slug and ensures it is unique within a provided array of existing slugs.
Feel free to submit issues and pull requests! Any contributions are welcome.
If you find this package helpful, consider supporting its development:
This project is licensed under the MIT License.
FAQs
Create unique URL-friendly slugs for your application
The npm package slug-wizard receives a total of 247 weekly downloads. As such, slug-wizard popularity was classified as not popular.
We found that slug-wizard demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.