Skip to content

Turbo is ignored on any navigation that uses a dot in the URL #480

@andrewjtait

Description

@andrewjtait

As of v7.1.0 form submissions do not use Turbo if the route includes a dot within its dynamic segment (https://guides.rubyonrails.org/routing.html#dynamic-segments)

For example, a form executing a POST to /domains/example.com

It looks as though the bug has been introduced as part of #437, which introduces an additional check for locationIsVisitable in this code:

turbo/src/core/session.ts

Lines 202 to 208 in aa9724d

willSubmitForm(form: HTMLFormElement, submitter?: HTMLElement): boolean {
const action = getAction(form, submitter)
return this.elementDriveEnabled(form)
&& (!submitter || this.elementDriveEnabled(submitter))
&& locationIsVisitable(expandURL(action), this.snapshot.rootLocation)
}

which is defined here:

turbo/src/core/url.ts

Lines 35 to 37 in 18c93e9

export function locationIsVisitable(location: URL, rootLocation: URL) {
return isPrefixedBy(location, rootLocation) && isHTML(location)
}

and checks the extension on the URL:

turbo/src/core/url.ts

Lines 26 to 28 in 18c93e9

export function isHTML(url: URL) {
return !!getExtension(url).match(/^(?:|\.(?:htm|html|xhtml))$/)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions