-
Notifications
You must be signed in to change notification settings - Fork 434
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
8 changed files
with
73 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
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,33 @@ | ||
import { TurboDriveTestCase } from "../helpers/turbo_drive_test_case" | ||
|
||
export class VisitableTests extends TurboDriveTestCase { | ||
path = "/src/tests/fixtures/visitable.html" | ||
|
||
async setup() { | ||
await this.goToLocation(this.path) | ||
} | ||
|
||
async "test user-defined visitable URL"() { | ||
await this.remote.execute(() => { | ||
window.Turbo.session.isVisitable = url => true | ||
}) | ||
|
||
this.clickSelector("#link") | ||
await this.nextBody | ||
this.assert.equal(await this.pathname, this.path) | ||
this.assert.equal(await this.visitAction, "advance") | ||
} | ||
|
||
async "test user-defined unvisitable URL"() { | ||
await this.remote.execute(() => { | ||
window.Turbo.session.isVisitable = url => false | ||
}) | ||
|
||
this.clickSelector("#link") | ||
await this.nextBody | ||
this.assert.equal(await this.pathname, this.path) | ||
this.assert.equal(await this.visitAction, "load") | ||
} | ||
} | ||
|
||
VisitableTests.registerSuite() |