[Pkg-javascript-commits] [less.js] 36/50: Fix #1987. First, res may be null if we have an error with a URL. Second, if the URL has no protocol, use http
Jonas Smedegaard
dr at jones.dk
Mon Oct 26 23:22:38 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag v1.7.1
in repository less.js.
commit ddfd1ca21bbad836ed2237272a0aa4d6a5fe9f69
Author: Luke Page <luke.a.page at gmail.com>
Date: Sun May 11 08:41:31 2014 +0100
Fix #1987. First, res may be null if we have an error with a URL. Second, if the URL has no protocol, use http
---
lib/less/index.js | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/less/index.js b/lib/less/index.js
index 9b8ee3f..9fd4d13 100644
--- a/lib/less/index.js
+++ b/lib/less/index.js
@@ -175,7 +175,16 @@ less.Parser.fileLoader = function (file, currentFileInfo, callback, env) {
var urlStr = isUrl ? file : url.resolve(currentFileInfo.currentDirectory, file),
urlObj = url.parse(urlStr);
+ if (!urlObj.protocol) {
+ urlObj.protocol = "http";
+ urlStr = urlObj.format();
+ }
+
request.get({uri: urlStr, strictSSL: !env.insecure }, function (error, res, body) {
+ if (error) {
+ callback({ type: 'File', message: "resource '" + urlStr + "' gave this Error:\n "+ error +"\n" });
+ return;
+ }
if (res.statusCode === 404) {
callback({ type: 'File', message: "resource '" + urlStr + "' was not found\n" });
return;
@@ -183,9 +192,6 @@ less.Parser.fileLoader = function (file, currentFileInfo, callback, env) {
if (!body) {
console.error( 'Warning: Empty body (HTTP '+ res.statusCode + ') returned by "' + urlStr +'"' );
}
- if (error) {
- callback({ type: 'File', message: "resource '" + urlStr + "' gave this Error:\n "+ error +"\n" });
- }
pathname = urlStr;
dirname = urlObj.protocol +'//'+ urlObj.host + urlObj.pathname.replace(/[^\/]*$/, '');
handleDataAndCallCallback(body);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git
More information about the Pkg-javascript-commits
mailing list