Browse Source

Fixes Microsoft/monaco-editor#717: use absolute paths when running under http

Alex Dima 7 years ago
parent
commit
e87b2e9445
1 changed files with 13 additions and 4 deletions
  1. 13 4
      test/index.html

+ 13 - 4
test/index.html

@@ -11,11 +11,20 @@
 <div id="container" style="width:800px;height:600px;border:1px solid grey"></div>
 <div id="container" style="width:800px;height:600px;border:1px solid grey"></div>
 
 
 <script>
 <script>
-	var require = {
-		paths: {
-			'vs/language/typescript': '../out',
-			'vs': '../node_modules/monaco-editor-core/dev/vs'
+	var paths = {
+		'vs/language/typescript': '../out',
+		'vs': '../node_modules/monaco-editor-core/dev/vs'
+	};
+	if (document.location.protocol === 'http:') {
+		// Add support for running local http server
+		let testIndex = document.location.pathname.indexOf('/test/');
+		if (testIndex !== -1) {
+			let prefix = document.location.pathname.substr(0, testIndex);
+			paths['vs/language/typescript'] = prefix + '/out';
 		}
 		}
+	}
+	var require = {
+		paths: paths
 	};
 	};
 </script>
 </script>
 <script src="../node_modules/monaco-editor-core/dev/vs/loader.js"></script>
 <script src="../node_modules/monaco-editor-core/dev/vs/loader.js"></script>