I just found out that AP.navigator.getLocation and the query param page.id might refer to the page visited before (not the current one) under the following conditions:
The current page is the home page of a space
The user used the breadcrumbs links to navigate to the space’s home page from another page in the space
Steps to reproduce:
Create a space with a home page and at least one child page
Ensure that you can use AP.navigator.getLocation on the space’s home page (alternative: have e.g. a webItem which consumes page.id)
Reload the space’s homepage and execute AP.navigator.getLocation - it returns the correct contentId
Navigate to a child page in the space
Navigate back to the space’s homepage using the breadcrumb links above the page’s title.
Execute AP.navigator.getLocation - its shows the contentId of the page visited before
I hadn’t noticed that exact problem, but had noticed an issue with custom overview (home) pages in spaces - it reports the default page, not the details of the app (it returns a different object for general pages). BTW page.id is deprecated.
You are right, the URL has the homepageId which I could use. However the content.id (thanks for pointing out the deprecation of page.id) is not correct for our webItem which points to a dialog.