gosimple / slug

URL-friendly slugify with multiple languages support.
Mozilla Public License 2.0
1.17k stars 109 forks source link

slug: Solve issue for IsSlug and numbers #12

Closed xescugc closed 7 years ago

xescugc commented 7 years ago

It was counting numbers as invalid characters in a slug, and they are not.

As the description says, [...]All output from slug.Make(text) shoud pass this test and I've found that if the text contains a number, the IsSlug returns false, an example:

package main

import (
    "fmt"

    "github.com/gosimple/slug"
)

func main() {
    text := "Some text 2 slugify"
    sl := slug.Make(text)
    fmt.Printf("Slugifyed text: %s\n", sl)
    fmt.Printf("(%s)IsSlug: %t\n", sl, slug.IsSlug(sl))
}

returns

Slugifyed text: some-text-2-slugify
(some-text-2-slugify)IsSlug: false
matrixik commented 7 years ago

I forgot about them... Thank you for this fix.