-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Unable to navigate on server without default index support (#1372)
* Fix: Cannot serve off `/.../index.html` Docsify must be hosted on a server that supports a default directory index (i.e. maps `/.../` -> `/.../index.html`). Some platforms do not support this, however. For example, HTML apps hosted on the popular game/software platform, Itch.io. This change supports hosting Docsify off an explicit path file, such as `/index.html`. It does this by: 1. Adding handling for paths like `index.html#/blah`, and 2. Normalising paths with fragments back to markdown paths For example, `http://example.org/index.html#/blah` would be mapped to `http://example.org/blah.md`. This fixes: #427 * Add end-to-end test for index file hosting * Add code comments for explicit file changes * Add additional tests for index file hosting * Add additional tests for index file hosting * [wip] Attempt to switch tests to Jest * Add e2e test for new Jest test framework * Verify sidebar links use file hosting * Fix: endsWith() not supported for IE11 * Refactor: utility method moved to utility file * Fix IE11 error from use of String.includes() Co-authored-by: John Hildenbiddle <jhildenbiddle@users.noreply.github.com>
- Loading branch information
1 parent
14ce7f3
commit 759ffac
Showing
3 changed files
with
73 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const docsifyInit = require('../helpers/docsify-init'); | ||
|
||
describe(`Index file hosting`, function() { | ||
const sharedOptions = { | ||
config: { | ||
basePath: `${TEST_HOST}/docs/index.html#/`, | ||
}, | ||
testURL: `${TEST_HOST}/docs/index.html#/`, | ||
}; | ||
|
||
test('should serve from index file', async () => { | ||
await docsifyInit(sharedOptions); | ||
|
||
await expect(page).toHaveText( | ||
'#main', | ||
'A magical documentation site generator' | ||
); | ||
expect(page.url()).toMatch(/index\.html#\/$/); | ||
}); | ||
|
||
test('should use index file links in sidebar from index file hosting', async () => { | ||
await docsifyInit(sharedOptions); | ||
|
||
await page.click('a[href="#/quickstart"]'); | ||
await expect(page).toHaveText('#main', 'Quick start'); | ||
expect(page.url()).toMatch(/index\.html#\/quickstart$/); | ||
}); | ||
}); |
759ffac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: