Skip to content

Commit

Permalink
Always go through the adapter to decide whether to start a visit or u…
Browse files Browse the repository at this point in the history
…pdate the window.location for external urls. This allows the turbo-ios and turbo-android adapters to see the proposed visits and handle them appropriately.
  • Loading branch information
jayohms committed Oct 30, 2023
1 parent 68bec03 commit a0f4583
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/core/drive/navigator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getVisitAction } from "../../util"
import { FormSubmission } from "./form_submission"
import { expandURL, getAnchor, getRequestURL, locationIsVisitable } from "../url"
import { expandURL, getAnchor, getRequestURL } from "../url"
import { Visit } from "./visit"
import { PageSnapshot } from "./page_snapshot"

Expand All @@ -11,11 +11,7 @@ export class Navigator {

proposeVisit(location, options = {}) {
if (this.delegate.allowsVisitingLocationWithAction(location, options.action)) {
if (locationIsVisitable(location, this.view.snapshot.rootLocation)) {
this.delegate.visitProposedToLocation(location, options)
} else {
window.location.href = location.toString()
}
this.delegate.visitProposedToLocation(location, options)
}
}

Expand Down Expand Up @@ -55,6 +51,10 @@ export class Navigator {
return this.delegate.view
}

get rootLocation() {
return this.view.snapshot.rootLocation
}

get history() {
return this.delegate.history
}
Expand Down
7 changes: 6 additions & 1 deletion src/core/native/browser_adapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ProgressBar } from "../drive/progress_bar"
import { SystemStatusCode } from "../drive/visit"
import { uuid, dispatch } from "../../util"
import { locationIsVisitable } from "../url"

export class BrowserAdapter {
progressBar = new ProgressBar()
Expand All @@ -10,7 +11,11 @@ export class BrowserAdapter {
}

visitProposedToLocation(location, options) {
this.navigator.startVisit(location, options?.restorationIdentifier || uuid(), options)
if (locationIsVisitable(location, this.navigator.rootLocation)) {
this.navigator.startVisit(location, options?.restorationIdentifier || uuid(), options)
} else {
window.location.href = location.toString()
}
}

visitStarted(visit) {
Expand Down

0 comments on commit a0f4583

Please sign in to comment.