File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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+
79102function normaliseFragment ( path ) {
80103 return path
81104 . split ( '/' )
You can’t perform that action at this time.
0 commit comments