All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alogient.cameleon.sdk.content.url.SEO2Generator Maven / Gradle / Ivy

The newest version!
package com.alogient.cameleon.sdk.content.url;

import java.text.Normalizer;

import org.apache.commons.lang.StringUtils;

public class SEO2Generator implements UrlMenuGenerator {
    /**
     * {@inheritDoc}
     */
    @Override
    public String generatePageUrl(String parentUrl, String pageName, String overrideUrl) {
        if (!StringUtils.isBlank(overrideUrl)) {
            return overrideUrl;
        }

        String pageUrlPart = pageName.toLowerCase();
        pageUrlPart = Normalizer.normalize(pageUrlPart, Normalizer.Form.NFD).replaceAll("[^a-z0-9]", " ");
        pageUrlPart = pageUrlPart.trim();
        pageUrlPart = pageUrlPart.replaceAll(" ", "-");
        while (pageUrlPart.contains("--")) {
            pageUrlPart = pageUrlPart.replaceFirst("--", "-");
        }

        return parentUrl + "/" + pageUrlPart;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy