mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 18:32:56 +01:00
More file protocol support
This commit is contained in:
parent
0b41054ac2
commit
f9905fad97
1 changed files with 16 additions and 3 deletions
|
|
@ -1,6 +1,15 @@
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var IS_FILE_PROTOCOL = (window.location.protocol === 'file:');
|
var IS_FILE_PROTOCOL = (window.location.protocol === 'file:');
|
||||||
|
var DIRNAME = null;
|
||||||
|
if (IS_FILE_PROTOCOL) {
|
||||||
|
var port = window.location.port;
|
||||||
|
if (port.length > 0) {
|
||||||
|
port = ':' + port;
|
||||||
|
}
|
||||||
|
DIRNAME = window.location.protocol + '//' + window.location.hostname + port + window.location.pathname.substr(0, window.location.pathname.lastIndexOf('/'));
|
||||||
|
}
|
||||||
|
console.log(DIRNAME);
|
||||||
|
|
||||||
var LOADER_OPTS = (function() {
|
var LOADER_OPTS = (function() {
|
||||||
function parseQueryString() {
|
function parseQueryString() {
|
||||||
|
|
@ -35,13 +44,13 @@
|
||||||
var resolvedPath = this.paths[this.selectedPath];
|
var resolvedPath = this.paths[this.selectedPath];
|
||||||
if (this.selectedPath === 'npm') {
|
if (this.selectedPath === 'npm') {
|
||||||
if (IS_FILE_PROTOCOL) {
|
if (IS_FILE_PROTOCOL) {
|
||||||
resolvedPath = '../' + resolvedPath;
|
resolvedPath = DIRNAME + '/../' + resolvedPath;
|
||||||
} else {
|
} else {
|
||||||
resolvedPath = '/monaco-editor/' + resolvedPath;
|
resolvedPath = '/monaco-editor/' + resolvedPath;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (IS_FILE_PROTOCOL) {
|
if (IS_FILE_PROTOCOL) {
|
||||||
resolvedPath = '../..' + resolvedPath;
|
resolvedPath = DIRNAME + '/../..' + resolvedPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resolvedPath;
|
return resolvedPath;
|
||||||
|
|
@ -66,7 +75,11 @@
|
||||||
if (search.length > 0) {
|
if (search.length > 0) {
|
||||||
search = '?' + search;
|
search = '?' + search;
|
||||||
}
|
}
|
||||||
var result = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + window.location.pathname + search + window.location.hash;
|
var port = window.location.port;
|
||||||
|
if (port.length > 0) {
|
||||||
|
port = ':' + port;
|
||||||
|
}
|
||||||
|
var result = window.location.protocol + '//' + window.location.hostname + port + window.location.pathname + search + window.location.hash;
|
||||||
// console.log(result);
|
// console.log(result);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue