Hi, first of all thank you for this useful package!
I've noticed that the current IsSlug function does not take into account the CustomSub defined via slug.CustomSub. This causes IsSlug to return false for strings that are technically valid slugs under custom substitution rules.
Example:
slug.CustomSub = map[string]string{
"_": "-", // convert underscores to dashes
}
slug.IsSlug("hello-world") // true
slug.IsSlug("hello_world") // returns true, but should be false based on substitution
Suggested fix:
I propose updating IsSlug to:
func IsSlug(text string) bool {
return text != "" && Make(text) == text
}
This way, IsSlug checks if the input is equal to what Make would return, taking into account all current configuration and substitutions.
Let me know what you think — I’d be happy to submit a PR if this change is acceptable.
Thanks again!
Hi, first of all thank you for this useful package!
I've noticed that the current IsSlug function does not take into account the CustomSub defined via slug.CustomSub. This causes IsSlug to return false for strings that are technically valid slugs under custom substitution rules.
Example:
Suggested fix:
I propose updating IsSlug to:
This way, IsSlug checks if the input is equal to what Make would return, taking into account all current configuration and substitutions.
Let me know what you think — I’d be happy to submit a PR if this change is acceptable.
Thanks again!