2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-11 18:02:32 +03:00

Added data URL support for node.js; (#4725)

* Added data URL support for node.js;
Added missed data URL protocol for the browser environment;
Optimized JSON parsing in the default response transformer;
Refactored project structure;
Added `cause` prop for AxiosError instance that refers to the original error if it was wrapped with `AxiosError.from` method;
Added fromDataURI helper;
Added test for handling data:url as an `arraybuffer|text|stream`;

* Added throwing of 405 HTTP error if the method is not GET;
This commit is contained in:
Dmitriy Mozgovoy
2022-05-20 09:04:36 +03:00
committed by GitHub
parent 63e559fa60
commit c30252f685
17 changed files with 226 additions and 48 deletions
+8 -7
View File
@@ -229,15 +229,16 @@ function trim(str) {
* navigator.product -> 'NativeScript' or 'NS'
*/
function isStandardBrowserEnv() {
if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
navigator.product === 'NativeScript' ||
navigator.product === 'NS')) {
var product;
if (typeof navigator !== 'undefined' && (
(product = navigator.product) === 'ReactNative' ||
product === 'NativeScript' ||
product === 'NS')
) {
return false;
}
return (
typeof window !== 'undefined' &&
typeof document !== 'undefined'
);
return typeof window !== 'undefined' && typeof document !== 'undefined';
}
/**