FransBouma / DocNet

Your friendly static documentation generator, using markdown files to build the content.
http://fransbouma.github.io/DocNet/
248 stars 36 forks source link

Do not encode targetUrl as it creates an issue when the home url contain a '/' #29

Closed seemantr closed 8 years ago

seemantr commented 8 years ago

This is a corner case which only happens when the __index page is under a folder like in the below case where all my paths are under docs folder. The url which gets generated (http://localhost:5000/docs%2foverview.html) has / replaced with %2f which changes the path.

{
    "Name": "FlexSearch",
    "Source": ".",
    "Destination": "..\\build",
    "Theme": "Default",
    "DefaultExtension": "html",
    "Pages": {
        "__index": "docs/overview.md",
        "FAQ": "docs/faq.md",
        "Getting Started": {
            "__index": "docs/getting-started.md",
            "Essential Path": {
                "Installing FlexSearch": "docs/server-setup/installing.md",
                "Setting up demo index": "docs/demo-index/setting-up-demo-index.md",
                "Search UI": "docs/demo-index/search-ui.md",
                "API Basics": "docs/rest/api-basics.md"
            }.....
FransBouma commented 8 years ago

The problem with removing the encode call is that any characters that need to be encoded are left as-is, including spaces.

Isn't a better solution to use System.Uri.EscapeUriString() instead? It will leave / and other url characters alone, but will encode spaces. bla/bla something.htm will become: bla/bla%20something.htm which is what we need :)

I'll change the UrlEncode with Uri.EscapeUriString().

(I didn't look into properly escaping this through the Uri class, I read this morning the HttpUtility uses Uri under the hood so I looked at that class and it's a better fit :))

FransBouma commented 8 years ago

Closed (fixed by better method)