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

Navigating to the turbo-root doesn't use Turbo Drive #912

Open
tobyzerner opened this issue Apr 22, 2023 · 0 comments · May be fixed by #913 or #1341
Open

Navigating to the turbo-root doesn't use Turbo Drive #912

tobyzerner opened this issue Apr 22, 2023 · 0 comments · May be fixed by #913 or #1341

Comments

@tobyzerner
Copy link

tobyzerner commented Apr 22, 2023

If you configure a Turbo root as follows:

<meta name="turbo-root" content="/app">

Turbo Drive will handle navigations to URLs within that root (like /app/foo), but not navigations to the root itself (/app).

We can see why this happens by following the logic from the locationIsVisitable function:

  1. locationIsVisitable is called
    • location = http://example.com/app
    • rootLocation = http://example.com/app
  2. These are passed into isPrefixedBy, which via getPrefix, adds a trailing slash to the root URL:
// location -> baseURL, rootLocation -> url
export function isPrefixedBy(baseURL: URL, url: URL) {
  const prefix = getPrefix(url) // = http://example.com/app/
  return baseURL.href === expandURL(prefix).href || baseURL.href.startsWith(prefix)
}
  1. Now the comparison is 'http://example.com/app' === 'http://example.com/app/' || 'http://example.com/app'.startsWith('http://example.com/app/'), which is false. No Turbo Drive.
tobyzerner added a commit to tobyzerner/turbo that referenced this issue Apr 22, 2023
leofeyer pushed a commit to contao/contao that referenced this issue Nov 21, 2024
Description
-----------

Reverts #7597 until hotwired/turbo#912 is fixed in Turbo.

Commits
-------

347c3d3 Revert "Add the `turbo-root` meta tag to the back end (see #7597)"
leofeyer pushed a commit to contao/core-bundle that referenced this issue Nov 21, 2024
Description
-----------

Reverts #7597 until hotwired/turbo#912 is fixed in Turbo.

Commits
-------

347c3d3e Revert "Add the `turbo-root` meta tag to the back end (see #7597)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant