Skip to content

Commit

Permalink
[BREAKING] Remove support for import over http(s)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
Import over http(s) is not supported anymore.
Use the Builder 'fs' option to provide an interface that also handles
http(s) resources.
  • Loading branch information
matz3 committed Nov 6, 2020
1 parent b6ed6e9 commit e4a1c86
Showing 1 changed file with 9 additions and 27 deletions.
36 changes: 9 additions & 27 deletions lib/thirdparty/less/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,36 +153,18 @@ less.Parser.fileLoader = function (file, currentFileInfo, callback, env) {

callback(null, data, pathname, newFileInfo);
}

var isUrl = isUrlRe.test( file );
if (isUrl || isUrlRe.test(currentFileInfo.currentDirectory)) {
if (request === undefined) {
try { request = require('request'); }
catch(e) { request = null; }
}
if (!request) {
callback({ type: 'File', message: "optional dependency 'request' required to import over http(s)\n" });
return;
}

var urlStr = isUrl ? file : url.resolve(currentFileInfo.currentDirectory, file),
urlObj = url.parse(urlStr);

request.get({uri: urlStr, strictSSL: !env.insecure }, function (error, res, body) {
if (res.statusCode === 404) {
callback({ type: 'File', message: "resource '" + urlStr + "' was not found\n" });
return;
}
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);
/* BEGIN MODIFICATION */
// Removed support for import over http(s) to get rid of 'request' dependency
callback({
type: 'File',
message: 'Import over http(s) is not supported anymore since less-openui5 v0.9.0\n' +
'Use the Builder \'fs\' option to provide an interface that also handles http(s) resources.\n'
});
return;
/* END MODIFICATION */
} else {

var paths = [currentFileInfo.currentDirectory].concat(env.paths);
Expand Down

0 comments on commit e4a1c86

Please sign in to comment.