Skip to content

Commit 8a488a2

Browse files
committed
Merge pull request #152 from 7anshuai/secure-baseurl
Make secure base url
2 parents 9a54299 + 6228b9d commit 8a488a2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

qiniu/rs.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,10 @@ GetPolicy.prototype.makeRequest = function(baseUrl, mac) {
267267

268268
return baseUrl + '&token=' + downloadToken;
269269
}
270+
271+
// domain maybe 'http://hello.qiniu.com', 'https://hello.qiniu.com' and 'hello.qiniu.com'
270272
// query like '-thumbnail', '?imageMogr2/thumbnail/960x' and so on
271273
function makeBaseUrl(domain, key, query) {
272274
key = new Buffer(key);
273-
return 'http://' + domain + '/' + querystring.escape(key) + (query || '');
275+
return (/^https?:\/\//.test(domain) ? domain : 'http://' + domain) + '/' + querystring.escape(key) + (query || '');
274276
}

0 commit comments

Comments
 (0)