Skip to content

Commit

Permalink
tweak all those copies of uriFromPath, #56691
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Aug 24, 2018
1 parent 8af86c7 commit 7a6a466
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 37 deletions.
3 changes: 1 addition & 2 deletions src/bootstrap-amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ var loader = require('./vs/loader');

function uriFromPath(_path) {
var pathName = path.resolve(_path).replace(/\\/g, '/');

if (pathName.length > 0 && pathName.charAt(0) !== '/') {
pathName = '/' + pathName;
}

return encodeURI('file://' + pathName);
return encodeURI('file://' + pathName).replace(/#/g, '%23');
}

function readFile(file) {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/code/electron-browser/issue/issueReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function uriFromPath(_path) {
pathName = '/' + pathName;
}

return encodeURI('file://' + pathName);
return encodeURI('file://' + pathName).replace(/#/g, '%23');
}

function readFile(file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function uriFromPath(_path) {
pathName = '/' + pathName;
}

return encodeURI('file://' + pathName);
return encodeURI('file://' + pathName).replace(/#/g, '%23');
}

function readFile(file) {
Expand Down
8 changes: 4 additions & 4 deletions src/vs/code/electron-browser/sharedProcess/sharedProcess.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ function uriFromPath(_path) {
pathName = '/' + pathName;
}

return encodeURI('file://' + pathName);
return encodeURI('file://' + pathName).replace(/#/g, '%23');
}

function readFile(file) {
return new Promise(function(resolve, reject) {
fs.readFile(file, 'utf8', function(err, data) {
return new Promise(function (resolve, reject) {
fs.readFile(file, 'utf8', function (err, data) {
if (err) {
reject(err);
return;
Expand Down Expand Up @@ -102,7 +102,7 @@ function main() {

if (nlsConfig._resolvedLanguagePackCoreLocation) {
let bundles = Object.create(null);
nlsConfig.loadBundle = function(bundle, language, cb) {
nlsConfig.loadBundle = function (bundle, language, cb) {
let result = bundles[bundle];
if (result) {
cb(undefined, result);
Expand Down
54 changes: 27 additions & 27 deletions src/vs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var _amdLoaderGlobal = this;
var AMDLoader;
(function (AMDLoader) {
AMDLoader.global = _amdLoaderGlobal;
var Environment = /** @class */ (function () {
var Environment = (function () {
function Environment() {
this._detected = false;
this._isWindows = false;
Expand Down Expand Up @@ -93,7 +93,7 @@ var AMDLoader;
*--------------------------------------------------------------------------------------------*/
var AMDLoader;
(function (AMDLoader) {
var LoaderEvent = /** @class */ (function () {
var LoaderEvent = (function () {
function LoaderEvent(type, detail, timestamp) {
this.type = type;
this.detail = detail;
Expand All @@ -102,7 +102,7 @@ var AMDLoader;
return LoaderEvent;
}());
AMDLoader.LoaderEvent = LoaderEvent;
var LoaderEventRecorder = /** @class */ (function () {
var LoaderEventRecorder = (function () {
function LoaderEventRecorder(loaderAvailableTimestamp) {
this._events = [new LoaderEvent(1 /* LoaderAvailable */, '', loaderAvailableTimestamp)];
}
Expand All @@ -115,7 +115,7 @@ var AMDLoader;
return LoaderEventRecorder;
}());
AMDLoader.LoaderEventRecorder = LoaderEventRecorder;
var NullLoaderEventRecorder = /** @class */ (function () {
var NullLoaderEventRecorder = (function () {
function NullLoaderEventRecorder() {
}
NullLoaderEventRecorder.prototype.record = function (type, detail) {
Expand All @@ -124,9 +124,9 @@ var AMDLoader;
NullLoaderEventRecorder.prototype.getEvents = function () {
return [];
};
NullLoaderEventRecorder.INSTANCE = new NullLoaderEventRecorder();
return NullLoaderEventRecorder;
}());
NullLoaderEventRecorder.INSTANCE = new NullLoaderEventRecorder();
AMDLoader.NullLoaderEventRecorder = NullLoaderEventRecorder;
})(AMDLoader || (AMDLoader = {}));
/*---------------------------------------------------------------------------------------------
Expand All @@ -135,14 +135,14 @@ var AMDLoader;
*--------------------------------------------------------------------------------------------*/
var AMDLoader;
(function (AMDLoader) {
var Utilities = /** @class */ (function () {
var Utilities = (function () {
function Utilities() {
}
/**
* This method does not take care of / vs \
*/
Utilities.fileUriToFilePath = function (isWindows, uri) {
uri = decodeURI(uri);
uri = decodeURI(uri).replace(/%23/g, '#');
if (isWindows) {
if (/^file:\/\/\//.test(uri)) {
// This is a URI without a hostname => return only the path segment
Expand Down Expand Up @@ -221,11 +221,11 @@ var AMDLoader;
}
return (this.HAS_PERFORMANCE_NOW ? AMDLoader.global.performance.now() : Date.now());
};
Utilities.NEXT_ANONYMOUS_ID = 1;
Utilities.PERFORMANCE_NOW_PROBED = false;
Utilities.HAS_PERFORMANCE_NOW = false;
return Utilities;
}());
Utilities.NEXT_ANONYMOUS_ID = 1;
Utilities.PERFORMANCE_NOW_PROBED = false;
Utilities.HAS_PERFORMANCE_NOW = false;
AMDLoader.Utilities = Utilities;
})(AMDLoader || (AMDLoader = {}));
/*---------------------------------------------------------------------------------------------
Expand All @@ -234,7 +234,7 @@ var AMDLoader;
*--------------------------------------------------------------------------------------------*/
var AMDLoader;
(function (AMDLoader) {
var ConfigurationOptionsUtil = /** @class */ (function () {
var ConfigurationOptionsUtil = (function () {
function ConfigurationOptionsUtil() {
}
/**
Expand Down Expand Up @@ -340,7 +340,7 @@ var AMDLoader;
return ConfigurationOptionsUtil;
}());
AMDLoader.ConfigurationOptionsUtil = ConfigurationOptionsUtil;
var Configuration = /** @class */ (function () {
var Configuration = (function () {
function Configuration(env, options) {
this._env = env;
this.options = ConfigurationOptionsUtil.mergeConfigurationOptions(options);
Expand Down Expand Up @@ -551,7 +551,7 @@ var AMDLoader;
/**
* Load `scriptSrc` only once (avoid multiple <script> tags)
*/
var OnlyOnceScriptLoader = /** @class */ (function () {
var OnlyOnceScriptLoader = (function () {
function OnlyOnceScriptLoader(env) {
this._env = env;
this._scriptLoader = null;
Expand Down Expand Up @@ -593,7 +593,7 @@ var AMDLoader;
};
return OnlyOnceScriptLoader;
}());
var BrowserScriptLoader = /** @class */ (function () {
var BrowserScriptLoader = (function () {
function BrowserScriptLoader() {
}
/**
Expand Down Expand Up @@ -626,7 +626,7 @@ var AMDLoader;
};
return BrowserScriptLoader;
}());
var WorkerScriptLoader = /** @class */ (function () {
var WorkerScriptLoader = (function () {
function WorkerScriptLoader() {
}
WorkerScriptLoader.prototype.load = function (moduleManager, scriptSrc, callback, errorback) {
Expand All @@ -640,7 +640,7 @@ var AMDLoader;
};
return WorkerScriptLoader;
}());
var NodeScriptLoader = /** @class */ (function () {
var NodeScriptLoader = (function () {
function NodeScriptLoader(env) {
this._env = env;
this._didInitialize = false;
Expand Down Expand Up @@ -847,9 +847,9 @@ var AMDLoader;
var timeout = minTimeout + Math.ceil(Math.random() * minTimeout);
setTimeout(callback, timeout);
};
NodeScriptLoader._BOM = 0xFEFF;
return NodeScriptLoader;
}());
NodeScriptLoader._BOM = 0xFEFF;
function createScriptLoader(env) {
return new OnlyOnceScriptLoader(env);
}
Expand All @@ -863,7 +863,7 @@ var AMDLoader;
(function (AMDLoader) {
// ------------------------------------------------------------------------
// ModuleIdResolver
var ModuleIdResolver = /** @class */ (function () {
var ModuleIdResolver = (function () {
function ModuleIdResolver(fromModuleId) {
var lastSlash = fromModuleId.lastIndexOf('/');
if (lastSlash !== -1) {
Expand Down Expand Up @@ -906,13 +906,13 @@ var AMDLoader;
}
return result;
};
ModuleIdResolver.ROOT = new ModuleIdResolver('');
return ModuleIdResolver;
}());
ModuleIdResolver.ROOT = new ModuleIdResolver('');
AMDLoader.ModuleIdResolver = ModuleIdResolver;
// ------------------------------------------------------------------------
// Module
var Module = /** @class */ (function () {
var Module = (function () {
function Module(id, strId, dependencies, callback, errorback, moduleIdResolver) {
this.id = id;
this.strId = strId;
Expand Down Expand Up @@ -1002,7 +1002,7 @@ var AMDLoader;
return Module;
}());
AMDLoader.Module = Module;
var ModuleIdProvider = /** @class */ (function () {
var ModuleIdProvider = (function () {
function ModuleIdProvider() {
this._nextId = 0;
this._strModuleIdToIntModuleId = new Map();
Expand All @@ -1029,17 +1029,17 @@ var AMDLoader;
};
return ModuleIdProvider;
}());
var RegularDependency = /** @class */ (function () {
var RegularDependency = (function () {
function RegularDependency(id) {
this.id = id;
}
RegularDependency.EXPORTS = new RegularDependency(0 /* EXPORTS */);
RegularDependency.MODULE = new RegularDependency(1 /* MODULE */);
RegularDependency.REQUIRE = new RegularDependency(2 /* REQUIRE */);
return RegularDependency;
}());
RegularDependency.EXPORTS = new RegularDependency(0 /* EXPORTS */);
RegularDependency.MODULE = new RegularDependency(1 /* MODULE */);
RegularDependency.REQUIRE = new RegularDependency(2 /* REQUIRE */);
AMDLoader.RegularDependency = RegularDependency;
var PluginDependency = /** @class */ (function () {
var PluginDependency = (function () {
function PluginDependency(id, pluginId, pluginParam) {
this.id = id;
this.pluginId = pluginId;
Expand All @@ -1048,7 +1048,7 @@ var AMDLoader;
return PluginDependency;
}());
AMDLoader.PluginDependency = PluginDependency;
var ModuleManager = /** @class */ (function () {
var ModuleManager = (function () {
function ModuleManager(env, scriptLoader, defineFunc, requireFunc, loaderAvailableTimestamp) {
if (loaderAvailableTimestamp === void 0) { loaderAvailableTimestamp = 0; }
this._env = env;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/electron-browser/bootstrap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function uriFromPath(_path) {
pathName = '/' + pathName;
}

return encodeURI('file://' + pathName);
return encodeURI('file://' + pathName).replace(/#/g, '%23');
}

function readFile(file) {
Expand Down
2 changes: 1 addition & 1 deletion test/electron/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function uriFromPath(_path) {
pathName = '/' + pathName;
}

return encodeURI('file://' + pathName);
return encodeURI('file://' + pathName).replace(/#/g, '%23');
}

function initLoader(opts) {
Expand Down

0 comments on commit 7a6a466

Please sign in to comment.