November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi Benjamin,
I'd probably go with implementing a custom IUrlSegmentGenerator, one that still uses the default functionality:
internal class CustomUrlSegmentGenerator : IUrlSegmentGenerator
{
private readonly IUrlSegmentGenerator _urlSegmentGenerator;
public CustomUrlSegmentGenerator(IUrlSegmentGenerator urlSegmentGenerator)
{
_urlSegmentGenerator = urlSegmentGenerator;
}
public string Create(string proposedSegment, UrlSegmentOptions options)
{
// Replace ø whilst maintaining case of the original
proposedSegment = Regex.Replace(proposedSegment, "ø", match => char.IsUpper(match.Value[0]) ? "OE" : "oe", RegexOptions.IgnoreCase);
return _urlSegmentGenerator.Create(proposedSegment, options);
}
public bool IsValid(string segment, UrlSegmentOptions options)
{
return _urlSegmentGenerator.IsValid(segment, options);
}
}
and the initialization module:
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class UrlSegmentGeneratorInitializer : IConfigurableModule
{
public void ConfigureContainer(ServiceConfigurationContext context)
{
context.Services.Intercept<IUrlSegmentGenerator>(
(locator, defaultUrlSegmentGenerator) => new CustomUrlSegmentGenerator(defaultUrlSegmentGenerator));
}
public void Initialize(InitializationEngine context) { }
public void Uninitialize(InitializationEngine context) { }
}
@Aniket: As far as I can see doesn't your code do something entriely different?
It wouldn't make any difference to the default segment for a page, but would it fact mean that if the user entered the URL:
/en/hellø
it would try to route it to:
/en/helloe
Hi Jake,
You are right. I misread the question. Deleting my comment to avoid confusion.
Aniket
Thanks Jake, this helped me with a similar situation, replacing double hypens from generated urls.
while (proposedSegment.Contains("--"))
{
proposedSegment = proposedSegment.Replace("--", "-");
}
Hello
When a page is created an URL is auto-generated that changes ø to o. Is there any way to change this behaviour so that ø becomes oe?
Thanks in advance.
Regards,
Benjamin