-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow URL based content-type guessing
Add `Session.isVisitable` method whitch is equivalent of no longer accessible `URL.isHTML`. This allows `Turbo.session.isVisitable` to be overriden by user and makes possible navigation on URL's other than those with trailing slash or HTML extenion.
- Loading branch information
Showing
7 changed files
with
70 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Visitable</title> | ||
<script src="/dist/turbo.es2017-umd.js" data-turbo-track="reload"></script> | ||
<script src="/src/tests/fixtures/test.js"></script> | ||
</head> | ||
<body> | ||
<h1>Visitable</h1> | ||
|
||
<div> | ||
<a id="link" href="/src/tests/fixtures/visitable.html">link</a> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { test } from "@playwright/test" | ||
import { assert } from "chai" | ||
import { nextBody, pathname, visitAction } from "../helpers/page" | ||
|
||
const path = "/src/tests/fixtures/visitable.html" | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto(path) | ||
}) | ||
|
||
test("test user-defined visitable URL", async ({ page }) => { | ||
await page.evaluate(() => { | ||
window.Turbo.session.isVisitable = (_url) => true | ||
}) | ||
|
||
page.click("#link") | ||
await nextBody(page) | ||
assert.equal(pathname(page.url()), path) | ||
assert.equal(await visitAction(page), "advance") | ||
}) | ||
|
||
test("test user-defined unvisitable URL", async ({ page }) => { | ||
await page.evaluate(() => { | ||
window.Turbo.session.isVisitable = (_url) => false | ||
}) | ||
|
||
page.click("#link") | ||
await nextBody(page) | ||
assert.equal(pathname(page.url()), path) | ||
assert.equal(await visitAction(page), "load") | ||
}) |