LWC NavigationMixin – NavigationMixin.Navigate for Communities URL Encodes the PageName

I am going through the documentation and things seem pretty straight forward:

{
    type: 'comm__namedPage',
    attributes: {
        pageName: 'home'
    }
}

However I need to set the pageName like so – pageName : 'case/5005578AVQAA2'. Or the whole piece of code would look like this:

this[NavigationMixin.Navigate]({
    type : 'comm__namedPage',                                                                     
    attributes : {
        pageName : 'case/5005578AVQAA2',
    },
});

What I found out is that when the url gets created that / character in the pageName gets urlEncoded and transformed to %2F.

So what the browser tries to navigate to is someCommunityUrl/case%2F5005578AVQAA2.

How do I prevent the url encoding? Is it happening for security reasons?

EDIT

Since documents are not supported I tried the same with Case and still get the same result.

Best Answer

Added based on comments

For navigating to any record, you should use standard__recordPage (provided, user has access to record). For example, for navigating to case:

import { LightningElement, wire, api, track } from 'lwc';
import { NavigationMixin, CurrentPageReference } from 'lightning/navigation';

export default class Poc extends NavigationMixin(LightningElement) {
    showRecord() {
        this[NavigationMixin.Navigate]({
            type: 'standard__recordPage',
            attributes: {
                recordId: '500280000068Gv7AAE',
                objectApiName: 'Case',
                actionName: 'view'
            }
        });
    }
}

OLD ANSWER

According to Documentation, Documents is not available in lightning experience. Even if you use pageReference standard__recordPage or standard__namedPage, you cannot access documents in lightning.


OLD ANSWER

In a community, you cannot even create a page with / in its name

enter image description here

Not sure if you are trying to view document but 5005578AVQAA2 is not an Id.