Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Preview url not correct for relative urls #27

Open
bjarnef opened this issue Nov 22, 2016 · 1 comment
Open

Preview url not correct for relative urls #27

bjarnef opened this issue Nov 22, 2016 · 1 comment

Comments

@bjarnef
Copy link
Contributor

bjarnef commented Nov 22, 2016

By default the "link to document" under properties tab is relative

image

When no hostnames has been assigned or e.g. mydomain.com has been assigned and I access backoffice from mydomain.com/umbraco the url is relative, but from my-project.s1.umbraco.io/umbraco (Umbraco Cloud), it then display the link to document as an absolute url.

So it should check for hostnames and it any isn't found (or if it is a relative url), it should use the current hostname.

image

In a project I have done something like this:

contentResource.getNiceUrl(eventId).then(function (url) {
    //console.log("url", url);
    var pageAbsoluteUrl = $location.protocol() + "://" + $location.host() + ":" + $location.port();
    if (url.indexOf('http://') === 0 || url.indexOf('https://') === 0)
    {
        pageAbsoluteUrl += "/" + url.replace(/^(?:\/\/|[^\/]+)*\//, "");
    }
    else {
        // relative url starts with "/"
        pageAbsoluteUrl += url;
    }

    //console.log("pageAbsoluteUrl", pageAbsoluteUrl);

    var exportUrl = "/Umbraco/Api/PdfDocument/GetPdfDocument?htmlFilePath=" + pageAbsoluteUrl + "?alttemplate=EventParticipants";
    $window.location.href = exportUrl;
});
@bjarnef
Copy link
Contributor Author

bjarnef commented Mar 10, 2017

I am still seing some issue with the preview url, which doesn't always display hostname.
E.g. for mysite.com with hostname mysite.com on root node and when accessing backoffice from this url, the link property under properties tab display a relative url.

Furthermore I noticed when using valid url's with e.g. Danish characters like æ, æ and å or a character like é, then then preview url omit these characters, even Umbraco display the url correct.
It confuse some of the editors since they think the url is broken.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant