Browse Source

fix: recognize shortened file:/path url

tophf 2 years ago
parent
commit
489c6fbb2f
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/common/util.js

+ 2 - 2
src/common/util.js

@@ -258,7 +258,7 @@ export async function requestLocalFile(url, options = {}) {
 }
 
 const isLocalUrlRe = re`/^(
-  file:\/\/|
+  file:|
   about:|
   data:|
   https?:\/\/
@@ -284,7 +284,7 @@ export const isRemote = url => url && !isLocalUrlRe.test(decodeURI(url));
  */
 export async function request(url, options = {}) {
   // fetch does not support local file
-  if (url.startsWith('file://')) return requestLocalFile(url, options);
+  if (url.startsWith('file:')) return requestLocalFile(url, options);
   const { body, headers, [kResponseType]: responseType } = options;
   const isBodyObj = body && body::({}).toString() === '[object Object]';
   const [, scheme, auth, hostname, urlTail] = url.match(/^([-\w]+:\/\/)([^@/]*@)?([^/]*)(.*)|$/);