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 1
1
{
2
2
"name" : " qiniu-js" ,
3
3
"jsName" : " qiniu" ,
4
- "version" : " 2.2.0 " ,
4
+ "version" : " 2.2.1 " ,
5
5
"private" : false ,
6
6
"description" : " Javascript SDK for Qiniu Resource (Cloud) Storage AP" ,
7
7
"main" : " dist/qiniu.min.js" ,
Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ export function getDomainFromUrl (url) {
201
201
202
202
// 构造区域上传url
203
203
export function getUploadUrl ( config , token ) {
204
- let protocol = window . location . protocol ;
204
+ let protocol = getAPIProtocol ( ) ;
205
205
if ( config . region != null ) {
206
206
let upHosts = regionUphostMap [ config . region ] ;
207
207
let host = config . useCdnDomain ? upHosts . cdnUphost : upHosts . srcUphost ;
@@ -214,6 +214,13 @@ export function getUploadUrl(config, token) {
214
214
} ) ;
215
215
}
216
216
217
+ function getAPIProtocol ( ) {
218
+ if ( window . location . protocol === "http:" ) {
219
+ return "http:" ;
220
+ }
221
+ return "https:" ;
222
+ }
223
+
217
224
function getPutPolicy ( token ) {
218
225
let segments = token . split ( ":" ) ;
219
226
let ak = segments [ 0 ] ;
@@ -226,7 +233,7 @@ function getPutPolicy(token) {
226
233
function getUpHosts ( token ) {
227
234
try {
228
235
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 ;
230
237
return request ( url , { method : "GET" } ) ;
231
238
} catch ( e ) {
232
239
return Promise . reject ( e ) ;
You can’t perform that action at this time.
0 commit comments