Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private string ResolveXhtml(string input)
{
Component comp = (Component)Engine.GetObject(uri);
// resolve youtube video
if (comp != null)
if (comp != null && comp.Metadata != null)
{
ItemFields fields = new ItemFields(comp.Metadata, comp.MetadataSchema);
ProcessFields(fields, link);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ namespace Sdl.Web.Common.Models
{
public class SitemapItem : EntityBase
{
//TODO: Make this configurable since its dependend on framework implementation
private const string DefaultExtension = ".html";

private string _url;

public SitemapItem()
Expand All @@ -29,7 +32,7 @@ public string Url

private static string ProcessUrl(string value)
{
return Path.HasExtension(value) ? value.Substring(0, value.Length - Path.GetExtension(value).Length) : value;
return Path.HasExtension(value) && DefaultExtension.Equals(Path.GetExtension(value)) ? value.Substring(0, value.Length - Path.GetExtension(value).Length) : value;
}

public string Type { get; set; }
Expand Down
6 changes: 4 additions & 2 deletions web-application/Sdl.Web.DD4T/Mapping/DD4TContentResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ public virtual string ResolveLink(object linkData, object resolveInstruction = n
if (url!=null && url.EndsWith(DefaultExtension))
{
url = url.Substring(0, url.Length - DefaultExtension.Length);
if (url.EndsWith("/" + DefaultExtensionLessPageName))
// Also strip the forward slash
var defaultPageNamePart = "/" + DefaultExtensionLessPageName;
if (url.EndsWith(defaultPageNamePart))
{
url = url.Substring(0, url.Length - DefaultExtensionLessPageName.Length);
url = url.Substring(0, url.Length - defaultPageNamePart.Length);
}
}
}
Expand Down