From 6228b9d59a8b515094581d464ab519474fad61b6 Mon Sep 17 00:00:00 2001 From: 7anshuai <7anshuai@gmail.com> Date: Thu, 19 Nov 2015 19:50:58 +0800 Subject: [PATCH] Make secure base url --- qiniu/rs.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qiniu/rs.js b/qiniu/rs.js index 6a5b74cf..5084426f 100644 --- a/qiniu/rs.js +++ b/qiniu/rs.js @@ -267,8 +267,10 @@ GetPolicy.prototype.makeRequest = function(baseUrl, mac) { return baseUrl + '&token=' + downloadToken; } + +// domain maybe 'http://hello.qiniu.com', 'https://hello.qiniu.com' and 'hello.qiniu.com' // query like '-thumbnail', '?imageMogr2/thumbnail/960x' and so on function makeBaseUrl(domain, key, query) { key = new Buffer(key); - return 'http://' + domain + '/' + querystring.escape(key) + (query || ''); + return (/^https?:\/\//.test(domain) ? domain : 'http://' + domain) + '/' + querystring.escape(key) + (query || ''); }