File tree 2 files changed +17
-6
lines changed
2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -76,12 +76,13 @@ export function fetchMixin(proto) {
76
76
} ;
77
77
78
78
proto . _fetch = function ( cb = noop ) {
79
+ const { basePath } = this . config ;
79
80
const { query } = this . route ;
80
81
let { path } = this . route ;
81
82
82
83
// Prevent loading remote content via URL hash
83
84
// Ex: https://foo.com/#//bar.com/file.md
84
- if ( isExternal ( path ) ) {
85
+ if ( isExternal ( path , basePath ) ) {
85
86
history . replaceState ( null , '' , '#' ) ;
86
87
this . router . normalize ( ) ;
87
88
} else {
@@ -92,7 +93,7 @@ export function fetchMixin(proto) {
92
93
const file = this . router . getFile ( path ) ;
93
94
const req = request ( file + qs , true , requestHeaders ) ;
94
95
95
- this . isRemoteUrl = isExternal ( file ) ;
96
+ this . isRemoteUrl = isExternal ( file , basePath ) ;
96
97
// Current page is html
97
98
this . isHTML = / \. h t m l $ / g. test ( file ) ;
98
99
Original file line number Diff line number Diff line change @@ -72,10 +72,20 @@ export function isFn(obj) {
72
72
* @param {String } string url
73
73
* @returns {Boolean } True if the passed-in url is external
74
74
*/
75
- export function isExternal ( url ) {
76
- let match = url . match (
77
- / ^ ( [ ^ : / ? # ] + : ) ? (?: \/ { 2 , } ( [ ^ / ? # ] * ) ) ? ( [ ^ ? # ] + ) ? ( \? [ ^ # ] * ) ? ( # .* ) ? /
78
- ) ;
75
+ export function isExternal ( url , basePath ) {
76
+ const regExp = / ^ ( [ ^ : / ? # ] + : ) ? (?: \/ { 2 , } ( [ ^ / ? # ] * ) ) ? ( [ ^ ? # ] + ) ? ( \? [ ^ # ] * ) ? ( # .* ) ? / ;
77
+ let match = url . match ( regExp ) ;
78
+
79
+ if ( basePath ) {
80
+ const matchWithBasePath = basePath . match ( regExp ) ;
81
+ if (
82
+ match && matchWithBasePath &&
83
+ match [ 1 ] === matchWithBasePath [ 1 ] &&
84
+ match [ 2 ] === matchWithBasePath [ 2 ]
85
+ ) {
86
+ return false ;
87
+ }
88
+ }
79
89
80
90
if (
81
91
typeof match [ 1 ] === 'string' &&
You can’t perform that action at this time.
0 commit comments