Browse Source

Support Host Relative URL

gilnoycloudinary 6 years ago
parent
commit
3843ca2241
1 changed files with 5 additions and 0 deletions
  1. 5 0
      examples/js/loaders/GLTFLoader.js

+ 5 - 0
examples/js/loaders/GLTFLoader.js

@@ -1246,6 +1246,11 @@ THREE.GLTFLoader = ( function () {
 
 		// Invalid URL
 		if ( typeof url !== 'string' || url === '' ) return '';
+		
+		// Host Relative URL
+		if (/^https?:\/\//i.test(path) && /^\//.test(url)) {
+      			path = path.replace(/(^https?:\/\/[^\/]+).*/i, "$1");
+		}
 
 		// Absolute URL http://,https://,//
 		if ( /^(https?:)?\/\//i.test( url ) ) return url;