Skip to content

dep-ts/slug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@dep/slug 🏷️

Tiny utility to create, compare, and validate URL-friendly slugs from strings.

JSR version

Features ✨

  • 📝 Convert any string to a clean, URL-friendly slug
  • 🔍 Compare two strings by their slugified versions
  • ✅ Validate if a string is a valid slug
  • ⚙️ Supports custom separators, lowercase option, and fallback values
  • 🚀 Works in Node.js, Deno, and browsers

Installation 📦

  • Deno:

    deno add jsr:@dep/slug
  • Node.js (18+) or Browsers:

    npx jsr add @dep/slug

    Then import as an ES module:

    import { compare, isSlug, slug, type SlugOptions } from "@dep/slug";

Usage 🎯

API 🧩

import { compare, isSlug, slug } from "@dep/slug";

// Convert string to slug
slug("Hello World!"); // 'hello-world'

// Compare two strings by slug
compare("Hello World!", "hello-world"); // true

// Validate a slug
isSlug("my-awesome-slug"); // true
isSlug("Invalid Slug!"); // false

// Options
slug("Hola Mundo", { separator: "_", lowercase: false }); // 'Hola_Mundo'

License 📄

MIT License – see LICENSE for details.

Author: Estarlin R (estarlincito.com)

About

Tiny utility to create, compare, and validate URL-friendly slugs from strings.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors