Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflect proxied document URL in top frame URL #478

Merged
merged 2 commits into from
May 6, 2021

Conversation

robertknight
Copy link
Member

@robertknight robertknight commented May 5, 2021

Update the URL of the top frame to reflect the proxied URL currently displayed in the content frame. This may be different than the initially requested URL if it redirected.

For example https://stackoverflow.com/questions/{id}/ redirects to https://stackoverflow.com/questions/{id}/{slug}. When visiting https://via.hypothes.is/https://stackoverflow.com/{id} the URL should be updated to https://via.hypothes.is/https://stackoverflow.com/{id}/{slug} accordingly.

Depends on hypothesis/viahtml#170 and fixes hypothesis/viahtml#156.

Testing:

  1. Check out Report proxied URL to parent frame viahtml#170 in the viahtml repo
  2. Check out this branch
  3. Visit http://localhost:9083/https://stackoverflow.com/questions/12339806/

Once the document has loaded, the URL should be updated to http://localhost:9083/https://stackoverflow.com/questions/12339806/escape-strings-for-javascript-using-jinja2.

When annotating PDFs the code here runs, but you won't see the expected effect due to #480.

Update the URL of the top frame to reflect the proxied URL currently
displayed in the content frame. This may be different than the initially
requested URL if it redirected.

For example https://stackoverflow.com/questions/<ID>/ redirects to
https://stackoverflow.com/questions/<ID>/<slug>. When visiting
https://via.hypothes.is/https://stackoverflow.com/<ID> the URL should be
updated to https://via.hypothes.is/https://stackoverflow.com/<ID>/<slug>
accordingly.

Depends on hypothesis/viahtml#170 and fixes
hypothesis/viahtml#156.
The URL passed to `replaceState` is resolved relative to the current
URL, so we don't need to specify the origin.
// in response to client-side URL changes in the iframe in future, we'll
// probably want to change this.
const viaURL = `/${metadata.location}`;
history.replaceState(null, document.title, viaURL);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nb. The url argument to replaceState is resolved relative to the current URL.

@robertknight robertknight requested a review from seanh May 6, 2021 08:22
@robertknight robertknight merged commit 6853883 into master May 6, 2021
@robertknight robertknight deleted the reflect-current-proxied-url branch May 6, 2021 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update the location bar URL when the iframe is navigated
2 participants