瀏覽代碼

fix: add https:// to digital oceans link (#4165)

Le Gia Hoang 2 年之前
父節點
當前提交
6e4fd9556d
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      packages/@uppy/aws-s3/src/index.js

+ 5 - 0
packages/@uppy/aws-s3/src/index.js

@@ -35,6 +35,11 @@ import isXml from './isXml.js'
 import locale from './locale.js'
 
 function resolveUrl (origin, link) {
+  // DigitalOcean doesn’t return the protocol from Location
+  // without it, the `new URL` constructor will fail
+  if (!origin && !link.startsWith('https://') && !link.startsWith('http://')) {
+    link = `https://${link}` // eslint-disable-line no-param-reassign
+  }
   return new URL(link, origin || undefined).toString()
 }