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

Update Visitable.visitableURL after following a redirect #156

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

calleluks
Copy link

Hi!

When reloading a page using pull-to-refresh after visiting a URL that redirects somewhere else, the original URL is reloaded instead of the URL that was redirected to.

This is inconsistent with how Turbolinks works in a browser where the address bar is updated using the History API causing reloading the page to reload the URL that was redirected to.

This happens both for cold boot visits and JavaScript visits.

This PR is an attempt to solve this problem by having the Turbolinks WebView adapter report back the final location after loading a page (for cold boot visits) or completing a visit (for JavaScript visits).

This might be a terrible solution but maybe it can help illustrate the problem?

I've also created a minimal Rails app that can be used to test this by changing ApplicationController.url to point to port 3000 in the demo app:

 import Turbolinks
 
 class ApplicationController: UINavigationController {
-    fileprivate let url = URL(string: "http://localhost:9292")!
+    fileprivate let url = URL(string: "http://localhost:3000")!
     fileprivate let webViewProcessPool = WKProcessPool()
 
     fileprivate var application: UIApplication {

When the demo app starts it will first GET / that will redirect to /redirect_target causing another GET for this path.

Before this PR, reloading the page using pull-to-refresh, would cause the same series of requests: GET / then GET /redirect_target.

After this PR, it only causes a GET /redirect_target.

The exact same behavior can be observed when clicking the "Go to /" link causing a JavaScript visit instead of a cold boot visit.

Previously, after visiting a URL that redirected to another URL,
pull-to-refresh would reload the original URL not the one that was
redirected to.

This is inconsistent with how Turbolinks works in a browser where the
address bar is updated using the History API causing reloading the page
to reload the URL that was redirected to.
@henrik
Copy link

henrik commented Aug 26, 2020

Pinging the Turbolinks devs. I've worked with Calle on our project using Turbolinks iOS and we're about to resume work on it :)

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

Successfully merging this pull request may close these issues.

2 participants