Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: fallback page should use path not file location #1301

Merged
merged 4 commits into from Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion cypress/fixtures/tpl/docs.index.html
Expand Up @@ -28,7 +28,7 @@
alias: {
'.*?/awesome':
'https://raw.githubusercontent.com/docsifyjs/awesome-docsify/master/README.md',
'.*?/changelog':
'/changelog':
'https://raw.githubusercontent.com/docsifyjs/docsify/master/CHANGELOG.md',
'/.*/_navbar.md': '/_navbar.md',
'/zh-cn/(.*)':
Expand All @@ -40,6 +40,7 @@
'/es/(.*)':
'https://raw.githubusercontent.com/docsifyjs/docs-es/master/$1'
},
fallbackLanguages: ['es'],
auto2top: true,
coverpage: true,
executeScript: true,
Expand Down
9 changes: 9 additions & 0 deletions cypress/integration/routing/fallback.spec.js
@@ -0,0 +1,9 @@
context('config.fallbackLanguages', () => {
it('fallbacks respecting aliases', () => {
cy.visit('http://localhost:3000/#/es/');

cy.get('.sidebar-nav').contains('Changelog').click();

cy.get('#main').should('contain', 'Bug Fixes');
})
});
6 changes: 4 additions & 2 deletions src/core/fetch/index.js
Expand Up @@ -123,7 +123,7 @@ export function fetchMixin(proto) {
this._loadSideAndNav(path, qs, loadSidebar, cb)
),
_ => {
this._fetchFallbackPage(file, qs, cb) || this._fetch404(file, qs, cb);
this._fetchFallbackPage(path, qs, cb) || this._fetch404(file, qs, cb);
}
);

Expand Down Expand Up @@ -209,7 +209,9 @@ export function fetchMixin(proto) {
return false;
}

const newPath = path.replace(new RegExp(`^/${local}`), '');
const newPath = this.router.getFile(
path.replace(new RegExp(`^/${local}`), '')
);
const req = request(newPath + qs, true, requestHeaders);

req.then(
Expand Down