@@ -472,6 +472,52 @@ func TestIsSlug(t *testing.T) {
472472 })
473473}
474474
475+ func TestSlugMakeDisableTrimOptions (t * testing.T ) {
476+ testCases := []struct {
477+ name string
478+ in string
479+ want string
480+ disableMultipleDash bool
481+ disableEndsTrim bool
482+ }{
483+ // Test multiple dash trim
484+ {"multiple dashes preserved" , "test--slug" , "test--slug" , true , false },
485+ {"multiple dashes and spaces" , "spaces converted to--dashes" , "spaces--converted--to--dashes" , true , false },
486+ {"symbols to multiple dashes" , "symbols!!!replaced" , "symbols---replaced" , true , false },
487+ {"only dashes multiple" , "----" , "" , true , false },
488+ {"only underscores multiple" , "____" , "" , true , false },
489+
490+ // Test end trim
491+ {"leading/trailing dashes" , "-test-slug-" , "-test-slug-" , false , true },
492+ {"leading/trailing underscores" , "_test_slug_" , "_test_slug_" , false , true },
493+ {"mixed endings" , "-_mixed_-" , "-_mixed_-" , false , true },
494+ {"only dashes end" , "----" , "-" , false , true },
495+ {"only underscores end" , "____" , "____" , false , true },
496+
497+ // Test both options together
498+ {"both options enabled" , "--test---slug--" , "--test---slug--" , true , true },
499+ {"multiple types of edges" , "__test---slug--" , "__test---slug--" , true , true },
500+ {"only dashes both" , "----" , "----" , true , true },
501+ {"only underscores both" , "____" , "____" , true , true },
502+ }
503+
504+ for _ , tc := range testCases {
505+ t .Run (tc .name , func (t * testing.T ) {
506+ DisableMultipleDashTrim = tc .disableMultipleDash
507+ DisableEndsTrim = tc .disableEndsTrim
508+ defer func () {
509+ DisableMultipleDashTrim = false
510+ DisableEndsTrim = false
511+ }()
512+
513+ got := Make (tc .in )
514+ if got != tc .want {
515+ t .Errorf ("Make(%#v) = %#v; want %#v" , tc .in , got , tc .want )
516+ }
517+ })
518+ }
519+ }
520+
475521func BenchmarkMakeShortAscii (b * testing.B ) {
476522 b .ReportAllocs ()
477523 for n := 0 ; n < b .N ; n ++ {
0 commit comments