This commit is contained in:
Namhyeon Go 2020-11-25 16:57:30 +09:00
parent cfc883aab6
commit d9dbdd8d74
2 changed files with 37 additions and 30 deletions

View File

@ -48,7 +48,9 @@ var FILE = require('lib/file');
var pos = url.indexOf('://'); var pos = url.indexOf('://');
var scheme = (pos < 0) ? "" : url.substring(0, pos); var scheme = (pos < 0) ? "" : url.substring(0, pos);
if (scheme == 'http' || scheme == 'https') { switch (scheme) {
case "http":
case "https":
var req = xmlHttp(); var req = xmlHttp();
if (!req) { if (!req) {
return; return;
@ -64,7 +66,9 @@ var FILE = require('lib/file');
return; return;
} }
req.send(null); req.send(null);
} else { break;
default:
responseText = FILE.readFile(url, "utf-8"); responseText = FILE.readFile(url, "utf-8");
callback(responseText); callback(responseText);
} }

View File

@ -392,11 +392,14 @@ var FILE = require('lib/file');
var pos = url.indexOf('://'); var pos = url.indexOf('://');
var scheme = (pos < 0) ? "" : url.substring(0, pos); var scheme = (pos < 0) ? "" : url.substring(0, pos);
if (scheme == 'http' || scheme == 'https') { switch (scheme) {
case "http":
case "https":
xhr.open("GET", url, false); xhr.open("GET", url, false);
xhr.send(); xhr.send();
return (xhr.status == 200) ? xhr.responseText : EMPTY_STRING; return (xhr.status == 200) ? xhr.responseText : EMPTY_STRING;
} else {
default:
var responseText = FILE.readFile(url, "utf-8"); var responseText = FILE.readFile(url, "utf-8");
return responseText; return responseText;
} }