package com.codenetworkz.blog.config;

import org.springframework.stereotype.Component;

import java.text.Normalizer;
@Component
public class SlugGenerator {

    public static String generateSlug(String input) {
        if (input == null || input.isEmpty()) {
            return "";
        }
        String lowerCase = Normalizer.normalize(input, Normalizer.Form.NFD)
                .replaceAll("\\p{M}", "")
                .toLowerCase().replaceAll("[^a-z0-9]+", "-")
                .replaceAll("^-|-$", "");

        return lowerCase;

    }
}
