Skip to content

Commit

Permalink
aws-s3: replace resolve-url by url-parse
Browse files Browse the repository at this point in the history
So it works in browser-ish, but non-DOM, environments. Will use the
global `URL` API if available, and fall back to url-parse, which has a
compatible-enough API.

Fixes #1720
  • Loading branch information
goto-bus-stop committed Sep 30, 2019
1 parent 91ee6af commit d6e11ce
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/@uppy/aws-s3-multipart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
},
"dependencies": {
"@uppy/companion-client": "file:../companion-client",
"@uppy/utils": "file:../utils",
"resolve-url": "^0.2.1"
"@uppy/utils": "file:../utils"
},
"peerDependencies": {
"@uppy/core": "^1.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/aws-s3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@uppy/companion-client": "file:../companion-client",
"@uppy/utils": "file:../utils",
"@uppy/xhr-upload": "file:../xhr-upload",
"resolve-url": "^0.2.1"
"url-parse": "^1.4.7"
},
"peerDependencies": {
"@uppy/core": "^1.0.0"
Expand Down
7 changes: 6 additions & 1 deletion packages/@uppy/aws-s3/src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
const resolveUrl = require('resolve-url')
// If global `URL` constructor is available, use it
const URL_ = typeof URL === 'function' ? URL : require('url-parse')
const { Plugin } = require('@uppy/core')
const Translator = require('@uppy/utils/lib/Translator')
const RateLimitedQueue = require('@uppy/utils/lib/RateLimitedQueue')
const { RequestClient } = require('@uppy/companion-client')
const XHRUpload = require('@uppy/xhr-upload')

function resolveUrl (origin, link) {
return new URL_(link, origin).toString()
}

function isXml (xhr) {
const contentType = xhr.headers ? xhr.headers['content-type'] : xhr.getResponseHeader('Content-Type')
return typeof contentType === 'string' && contentType.toLowerCase() === 'application/xml'
Expand Down

0 comments on commit d6e11ce

Please sign in to comment.