diff --git a/bin/debug.bat b/bin/debug.bat new file mode 100644 index 00000000..d73571ee --- /dev/null +++ b/bin/debug.bat @@ -0,0 +1 @@ +java -cp rhino/js.jar org.mozilla.javascript.tools.debugger.Main envjs/rhino.js %* diff --git a/bin/envjs.bat b/bin/envjs.bat new file mode 100644 index 00000000..07be351a --- /dev/null +++ b/bin/envjs.bat @@ -0,0 +1 @@ +java -Xmx512M -jar rhino/js.jar -opt -1 envjs/rhino.js %* diff --git a/envjs/platform/core.js b/envjs/platform/core.js index 9d53a2cf..d48302ab 100644 --- a/envjs/platform/core.js +++ b/envjs/platform/core.js @@ -2763,6 +2763,7 @@ Envjs.getcwd = function() { * @param {Object} base (semi-optional) The base url used in resolving "path" above */ Envjs.uri = function(path, base) { + path = path.replace(/\\/g, '/'); //console.log('constructing uri from path %s and base %s', path, base); path = path+''; // Semi-common trick is to make an iframe with src='javascript:false' @@ -2777,6 +2778,12 @@ Envjs.uri = function(path, base) { return urlparse.urlnormalize(path); } + // if path is a Windows style absolute path (C:\foo\bar\index.html) + // make it a file: URL + if (path.match('^[a-zA-Z]+:/')) { + return 'file:///' + urlparse.urlnormalize(path); + } + // interesting special case, a few very large websites use // '//foo/bar/' to mean 'http://foo/bar' if (path.match('^//')) { @@ -2798,7 +2805,7 @@ Envjs.uri = function(path, base) { // if base is still empty, then we are in QA mode loading local // files. Get current working directory if (!base) { - base = 'file://' + Envjs.getcwd() + '/'; + base = 'file:///' + (""+Envjs.getcwd()).replace(/\\/g, '/') + '/'; } // handles all cases if path is abosulte or relative to base // 3rd arg is "false" --> remove fragments @@ -2884,13 +2891,15 @@ Envjs.localXHR = function(url, xhr, connection, data){ xhr.statusText = "ok"; xhr.responseText = Envjs.readFromFile(url); try{ - if(url.match(/html$/)){ + //url as passed in here might be an object, so stringify it + var urlstring = url.toString(); + if(urlstring.match(/html$/)){ xhr.responseHeaders["Content-Type"] = 'text/html'; - }else if(url.match(/.xml$/)){ + }else if(urlstring.match(/.xml$/)){ xhr.responseHeaders["Content-Type"] = 'text/xml'; - }else if(url.match(/.js$/)){ + }else if(urlstring.match(/.js$/)){ xhr.responseHeaders["Content-Type"] = 'text/javascript'; - }else if(url.match(/.json$/)){ + }else if(urlstring.match(/.json$/)){ xhr.responseHeaders["Content-Type"] = 'application/json'; }else{ xhr.responseHeaders["Content-Type"] = 'text/plain'; @@ -2914,6 +2923,7 @@ Envjs.localXHR = function(url, xhr, connection, data){ __extend__(Envjs, urlparse); }(/*Envjs.XMLHttpRequest.Core*/)); + (function(){ var log = Envjs.logger('Envjs.Window'); diff --git a/src/platform/core/xhr.js b/src/platform/core/xhr.js index 50060e53..70e28d28 100644 --- a/src/platform/core/xhr.js +++ b/src/platform/core/xhr.js @@ -151,13 +151,15 @@ Envjs.localXHR = function(url, xhr, connection, data){ xhr.statusText = "ok"; xhr.responseText = Envjs.readFromFile(url); try{ - if(url.match(/html$/)){ + //url as passed in here might be an object, so stringify it + var urlstring = url.toString(); + if(urlstring.match(/html$/)){ xhr.responseHeaders["Content-Type"] = 'text/html'; - }else if(url.match(/.xml$/)){ + }else if(urlstring.match(/.xml$/)){ xhr.responseHeaders["Content-Type"] = 'text/xml'; - }else if(url.match(/.js$/)){ + }else if(urlstring.match(/.js$/)){ xhr.responseHeaders["Content-Type"] = 'text/javascript'; - }else if(url.match(/.json$/)){ + }else if(urlstring.match(/.json$/)){ xhr.responseHeaders["Content-Type"] = 'application/json'; }else{ xhr.responseHeaders["Content-Type"] = 'text/plain';