Do not derive one from the other, and do not build them from
window.location: inside a native shell your page may be running on a host nobody else can reach.
Routing
The same bundle is mounted at/ on the app’s host and at /<slug> on a profile. The host tells you which.
Shareable links
userPageUrl for anything a person will paste elsewhere: a share sheet, a copied link, a preview card. When the page is already the owner’s own user page, it keeps the current origin, so a profile reached through a custom domain shares as that domain.
getHostnameUsername
Returns the profile owner’s username: from the injected app data when present, otherwise from the first label of the hostname. Onlocalhost it returns a fixed development name. Prefer getAppUser() in new code.