Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for relative URLs & remote imagess #4

Merged
merged 1 commit into from Jul 5, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 17 additions & 6 deletions lib/image-proxy.js
Expand Up @@ -15,14 +15,25 @@ module.exports = function () {
var fileExt = path.extname(remoteUrl);
var urlHost = urlObject.hostname;

var tempImageFile = temp.path({suffix: fileExt});
// console.log(urlObject.hostname + ' - ' + req.headers.host);

if(urlObject.hostname == undefined)
{
options = url.parse("http://" + req.headers.host + "" + remoteUrl);
}
else
{
if(urlObject.port != undefined)
urlHost += ":"+urlObject.port;

if(urlObject.port != undefined)
urlHost += ":"+urlObject.port;
// In future perhaps allow user to provide a whitelist of hosts to proxy for
// if(urlHost != req.headers.host)
// throw('Error: Only local proxy allowed.' + urlHost + " " + req.headers.host);

// In future perhaps allow user to provide a whitelist of hosts to proxy for
if(urlHost != req.headers.host)
throw('Error: Only local proxy allowed.' + urlHost + " " + req.headers.host);
}


var tempImageFile = temp.path({suffix: fileExt});

http.get(options, function(image_res) {

Expand Down