Skip to content

Commit f940526

Browse files
committed
Add code comments for explicit file changes
1 parent 53992cc commit f940526

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/core/router/history/hash.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export class HashHistory extends History {
1818
const path = window.location.pathname || '';
1919
const base = this.config.basePath;
2020

21+
// This handles the case where Docsify is served off an
22+
// explicit file path, i.e.`/base/index.html#/blah`. This
23+
// prevents the `/index.html` part of the URI from being
24+
// remove during routing.
25+
// See here: https://github.com/docsifyjs/docsify/pull/1372
2126
const basePath = path.endsWith('.html')
2227
? path + '#/' + base
2328
: path + '/' + base;

src/core/router/util.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,29 @@ export const resolvePath = cached(path => {
7676
return '/' + resolved.join('/');
7777
});
7878

79+
/**
80+
* Normalises the URI path to handle the case where Docsify is
81+
* hosted off explicit files, i.e. /index.html. This function
82+
* eliminates any path segments that contain `#` fragments.
83+
*
84+
* This is used to map browser URIs to markdown file sources.
85+
*
86+
* For example:
87+
*
88+
* http://example.org/base/index.html#/blah
89+
*
90+
* would be mapped to:
91+
*
92+
* http://example.org/base/blah.md.
93+
*
94+
* See here for more information:
95+
*
96+
* https://github.com/docsifyjs/docsify/pull/1372
97+
*
98+
* @param {string} path The URI path to normalise
99+
* @return {string} { path, query }
100+
*/
101+
79102
function normaliseFragment(path) {
80103
return path
81104
.split('/')

0 commit comments

Comments
 (0)