Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #6 #7

Merged
Merged
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Where docTypeName is the document type alias to be treated as a "virtual" node.
You can define multiple "rules" by separating them with commas, e.g.

```xml
<add key="virtualnode" value="docTypeName,anotherDocType"/>
<add key="VirtualNodes" value="docTypeName,anotherDocType"/>
```

You can also use wildcards at the start and/or the end of the document type alias, like this:

```xml
<add key="virtualnode" value="dog*,*cat,*mouse*"/>
<add key="VirtualNodes" value="dog*,*cat,*mouse*"/>
```
This means that all document type aliases ending with "dog", starting with "cat" or containing "mouse" will be treated as virtual nodes.

Expand Down
9 changes: 8 additions & 1 deletion VirtualNodes/VirtualNodesUrlProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private UrlInfo ConstructUrl(UmbracoContext umbracoContext, IPublishedContent co
var urlText = url == null ? "" : url.Text;

// If we come from an absolute URL, strip the host part and keep it so that we can append
// it again when returing the URL.
// it again when returning the URL.
var hostPart = "";

if (urlText.StartsWith("http"))
Expand All @@ -96,7 +96,14 @@ private UrlInfo ConstructUrl(UmbracoContext umbracoContext, IPublishedContent co
}

// Now split the url. We should have as many elements as those in pathIds.
// - Unless the top-level node provided a folder-style hostname
string[] urlParts = urlText.Split('/').Reverse().ToArray();
var hasHostnameFolder = urlParts.Length > pathIds.Length;
if (hasHostnameFolder)
{
//recalc the pathIds
pathIds = path.Split(',').Skip(pathItemsToSkip-1).Reverse().ToArray();
}

// Iterate the url parts. Check the corresponding path id and if the document that corresponds there
// is of a type that must be excluded from the path, just make that url part an empty string.
Expand Down