From 24ffa5e91457195efb7fe88885d5a1e2f60c44c2 Mon Sep 17 00:00:00 2001 From: Hiroyuki Sano Date: Fri, 7 Aug 2015 16:02:44 +0900 Subject: [PATCH] Use mount point instead of remote path on JavaScript --- lib/web_console/templates/_markup.html.erb | 3 ++- lib/web_console/templates/console.js.erb | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/web_console/templates/_markup.html.erb b/lib/web_console/templates/_markup.html.erb index 97181d90..96d48769 100644 --- a/lib/web_console/templates/_markup.html.erb +++ b/lib/web_console/templates/_markup.html.erb @@ -1,4 +1,5 @@
diff --git a/lib/web_console/templates/console.js.erb b/lib/web_console/templates/console.js.erb index de55f2a7..2119b2a0 100644 --- a/lib/web_console/templates/console.js.erb +++ b/lib/web_console/templates/console.js.erb @@ -60,15 +60,17 @@ function REPLConsole(config) { this.commandStorage = new CommandStorage(); this.prompt = getConfig('promptLabel', ' >>'); - this.remotePath = getConfig('remotePath'); + this.mountPoint = getConfig('mountPoint'); + this.sessionId = getConfig('sessionId'); } -REPLConsole.prototype.getUrl = function(path) { +REPLConsole.prototype.getSessionUrl = function(path) { + var parts = [ this.mountPoint, 'repl_sessions', this.sessionId ]; if (path) { - return this.remotePath + '/' + path; - } else { - return this.remotePath; + parts.push(path); } + // Join and remove duplicate slashes. + return parts.join('/').replace(/([^:]\/)\/+/g, '$1'); }; REPLConsole.prototype.commandHandle = function(line, callback) { @@ -96,7 +98,7 @@ REPLConsole.prototype.commandHandle = function(line, callback) { } } - putRequest(self.getUrl(), params, function(xhr) { + putRequest(self.getSessionUrl(), params, function(xhr) { var response = parseJSON(xhr.responseText); var result = isSuccess(xhr.status); if (result) { @@ -448,7 +450,7 @@ REPLConsole.prototype.scrollToBottom = function() { // Change the binding of the console REPLConsole.prototype.switchBindingTo = function(frameId, callback) { - var url = this.remotePath + "/trace"; + var url = this.getSessionUrl('trace'); var params = "frame_id=" + encodeURIComponent(frameId); postRequest(url, params, callback); };