-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/axios/axios into feat/par…
…amsSerializer
- Loading branch information
Showing
20 changed files
with
358 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const {spawn} = require('child_process'); | ||
|
||
const args = process.argv.slice(2); | ||
|
||
console.log(`Running ${args.join(' ')} on ${process.version}\n`); | ||
|
||
const match = /v(\d+)/.exec(process.version); | ||
|
||
const isHotfixNeeded = match && match[1] > 16; | ||
|
||
isHotfixNeeded && console.warn('Setting --openssl-legacy-provider as ssl hotfix'); | ||
|
||
const test = spawn('cross-env', | ||
isHotfixNeeded ? ['NODE_OPTIONS=--openssl-legacy-provider', ...args] : args, { | ||
shell: true, | ||
stdio: 'inherit' | ||
} | ||
); | ||
|
||
test.on('exit', function (code) { | ||
process.exit(code) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use strict'; | ||
|
||
var AxiosError = require('../core/AxiosError'); | ||
var parseProtocol = require('./parseProtocol'); | ||
var platform = require('../platform'); | ||
|
||
var DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/; | ||
|
||
/** | ||
* Parse data uri to a Buffer or Blob | ||
* @param {String} uri | ||
* @param {?Boolean} asBlob | ||
* @param {?Object} options | ||
* @param {?Function} options.Blob | ||
* @returns {Buffer|Blob} | ||
*/ | ||
module.exports = function fromDataURI(uri, asBlob, options) { | ||
var _Blob = options && options.Blob || platform.classes.Blob; | ||
var protocol = parseProtocol(uri); | ||
|
||
if (asBlob === undefined && _Blob) { | ||
asBlob = true; | ||
} | ||
|
||
if (protocol === 'data') { | ||
uri = protocol.length ? uri.slice(protocol.length + 1) : uri; | ||
|
||
var match = DATA_URL_PATTERN.exec(uri); | ||
|
||
if (!match) { | ||
throw new AxiosError('Invalid URL', AxiosError.ERR_INVALID_URL); | ||
} | ||
|
||
var mime = match[1]; | ||
var isBase64 = match[2]; | ||
var body = match[3]; | ||
var buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8'); | ||
|
||
if (asBlob) { | ||
if (!_Blob) { | ||
throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT); | ||
} | ||
|
||
return new _Blob([buffer], {type: mime}); | ||
} | ||
|
||
return buffer; | ||
} | ||
|
||
throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT); | ||
}; |
Oops, something went wrong.