Browse Source

Fix File Loading if hosted from `file:`-Protocol

Lukas Tetzlaff 7 years ago
parent
commit
f47b2c232e
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/Tools/babylon.tools.ts

+ 5 - 1
src/Tools/babylon.tools.ts

@@ -753,7 +753,7 @@
                             // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
                             request.removeEventListener("readystatechange", onReadyStateChange);
 
-                            if (request.status >= 200 && request.status < 300 || (!Tools.IsWindowObjectExist() && (request.status === 0))) {
+                            if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!Tools.IsWindowObjectExist() || Tools.IsFileURL()))) {
                                 onSuccess(!useArrayBuffer ? request.responseText : <ArrayBuffer>request.response, request.responseURL);
                                 return;
                             }
@@ -1505,6 +1505,10 @@
                 Tools.Error = Tools._ErrorDisabled;
             }
         }
+	    
+	public static IsFileURL(): boolean {
+	    return location.protocol === "file:";
+	}
 
         public static IsWindowObjectExist(): boolean {
             return (typeof window) !== "undefined";