This repository was archived by the owner on Mar 1, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +37
-3
lines changed
Expand file tree Collapse file tree 3 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ cli.command(
2727 } )
2828 . strict ( ) . help ( ) ,
2929 async ( args ) => {
30- const force = args . force ?? false ;
30+ const _force = args . force ?? false ;
3131 const versions = Array . isArray ( args . versions ) ? args . versions : [ args . versions ] ;
3232
3333 if ( SUPPORTED_EMOJI_VERSIONS . every ( ( v ) => ! versions . includes ( v ) ) ) {
Original file line number Diff line number Diff line change 11export function slugify ( val : string ) : string {
22 return val . normalize ( "NFD" )
3+ . toLowerCase ( )
4+ . trim ( )
35 . replace ( / [ \u0300 - \u036F ] / g, "" )
46 . replace ( / \( .+ \) / g, "" )
5- . trim ( )
67 . replace ( "&" , "" )
7- . replace ( / [ \W _ ] + / g, "-" ) . toLowerCase ( ) ;
8+ . replace ( / [ \W _ ] + / g, "-" )
9+ . replace ( / ^ - + | - + $ / g, "" ) ;
810}
Original file line number Diff line number Diff line change 1+ import { describe , expect , it } from "vitest" ;
2+ import { slugify } from "../src/utils" ;
3+
4+ describe ( "slugify" , ( ) => {
5+ it ( "should convert string to slug format" , ( ) => {
6+ expect ( slugify ( "Hello World" ) ) . toBe ( "hello-world" ) ;
7+ } ) ;
8+
9+ it ( "should remove diacritics" , ( ) => {
10+ expect ( slugify ( "héllo wörld" ) ) . toBe ( "hello-world" ) ;
11+ } ) ;
12+
13+ it ( "should remove parentheses and their content" , ( ) => {
14+ expect ( slugify ( "hello (world)" ) ) . toBe ( "hello" ) ;
15+ } ) ;
16+
17+ it ( "should trim whitespace" , ( ) => {
18+ expect ( slugify ( " hello world " ) ) . toBe ( "hello-world" ) ;
19+ } ) ;
20+
21+ it ( "should remove ampersands" , ( ) => {
22+ expect ( slugify ( "hello & world" ) ) . toBe ( "hello-world" ) ;
23+ } ) ;
24+
25+ it ( "should replace special characters with hyphens" , ( ) => {
26+ expect ( slugify ( "hello_world!@#$%^" ) ) . toBe ( "hello-world" ) ;
27+ } ) ;
28+
29+ it ( "should convert to lowercase" , ( ) => {
30+ expect ( slugify ( "HELLO WORLD" ) ) . toBe ( "hello-world" ) ;
31+ } ) ;
32+ } ) ;
You can’t perform that action at this time.
0 commit comments