toURLEncodedForm.js 548 B

123456789101112131415161718
  1. 'use strict';
  2. import utils from '../utils.js';
  3. import toFormData from './toFormData.js';
  4. import platform from '../platform/index.js';
  5. export default function toURLEncodedForm(data, options) {
  6. return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
  7. visitor: function(value, key, path, helpers) {
  8. if (platform.isNode && utils.isBuffer(value)) {
  9. this.append(key, value.toString('base64'));
  10. return false;
  11. }
  12. return helpers.defaultVisitor.apply(this, arguments);
  13. }
  14. }, options));
  15. }