File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " qiniu-js" ,
33 "jsName" : " qiniu" ,
4- "version" : " 2.2.0 " ,
4+ "version" : " 2.2.1 " ,
55 "private" : false ,
66 "description" : " Javascript SDK for Qiniu Resource (Cloud) Storage AP" ,
77 "main" : " dist/qiniu.min.js" ,
Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ export function getDomainFromUrl (url) {
201201
202202// 构造区域上传url
203203export function getUploadUrl ( config , token ) {
204- let protocol = window . location . protocol ;
204+ let protocol = getAPIProtocol ( ) ;
205205 if ( config . region != null ) {
206206 let upHosts = regionUphostMap [ config . region ] ;
207207 let host = config . useCdnDomain ? upHosts . cdnUphost : upHosts . srcUphost ;
@@ -214,6 +214,13 @@ export function getUploadUrl(config, token) {
214214 } ) ;
215215}
216216
217+ function getAPIProtocol ( ) {
218+ if ( window . location . protocol === "http:" ) {
219+ return "http:" ;
220+ }
221+ return "https:" ;
222+ }
223+
217224function getPutPolicy ( token ) {
218225 let segments = token . split ( ":" ) ;
219226 let ak = segments [ 0 ] ;
@@ -226,7 +233,7 @@ function getPutPolicy(token) {
226233function getUpHosts ( token ) {
227234 try {
228235 let putPolicy = getPutPolicy ( token ) ;
229- let url = window . location . protocol + "//api.qiniu.com/v2/query?ak=" + putPolicy . ak + "&bucket=" + putPolicy . bucket ;
236+ let url = getAPIProtocol ( ) + "//api.qiniu.com/v2/query?ak=" + putPolicy . ak + "&bucket=" + putPolicy . bucket ;
230237 return request ( url , { method : "GET" } ) ;
231238 } catch ( e ) {
232239 return Promise . reject ( e ) ;
You can’t perform that action at this time.
0 commit comments