ionic-native-http-connection-backend
Version:
A solution to CORS problem with Ionic and WKWebView
33 lines • 916 B
JavaScript
import { HttpParams } from '@angular/common/http';
import { collectionToObject } from './collection-to-object';
export var queryToObject = function (query) {
if (!query) {
return {};
}
return (/^[?#]/.test(query) ? query.slice(1) : query)
.split('&')
.reduce(function (params, param) {
var _a = param.split('='), key = _a[0], value = _a[1];
params[key] = value
? decodeURIComponent(value.replace(/\+/g, ' '))
: '';
return params;
}, {});
};
export var bodyToObject = function (body) {
if (typeof body === 'string') {
try {
return JSON.parse(body);
}
catch (e) {
return queryToObject(body);
}
}
else if (body instanceof HttpParams) {
return collectionToObject(body);
}
else {
return body;
}
};
//# sourceMappingURL=http-params.js.map