Browse Source

Merge pull request #15618 from gilnoycloudinary/dev

GLTFLoader  - Support Host Relative URL
Mr.doob 6 years ago
parent
commit
50d7a5b3a6
1 changed files with 7 additions and 0 deletions
  1. 7 0
      examples/js/loaders/GLTFLoader.js

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

@@ -1187,6 +1187,13 @@ THREE.GLTFLoader = ( function () {
 
 
 		// Invalid URL
 		// Invalid URL
 		if ( typeof url !== 'string' || url === '' ) return '';
 		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://,//
 		// Absolute URL http://,https://,//
 		if ( /^(https?:)?\/\//i.test( url ) ) return url;
 		if ( /^(https?:)?\/\//i.test( url ) ) return url;