f35de65be172d1a12a348ce3f2b3f41f107e54023bc408b81748c7b2dee2ba469050774da5abbefea828b8869c9e9b37c5d1d8da97391d3f8e8b112e2feb65 921 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. 'use strict';
  2. var toFormData = require('./toFormData');
  3. function encode(str) {
  4. var charMap = {
  5. '!': '%21',
  6. "'": '%27',
  7. '(': '%28',
  8. ')': '%29',
  9. '~': '%7E',
  10. '%20': '+',
  11. '%00': '\x00'
  12. };
  13. return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, function replacer(match) {
  14. return charMap[match];
  15. });
  16. }
  17. function AxiosURLSearchParams(params, options) {
  18. this._pairs = [];
  19. params && toFormData(params, this, options);
  20. }
  21. var prototype = AxiosURLSearchParams.prototype;
  22. prototype.append = function append(name, value) {
  23. this._pairs.push([name, value]);
  24. };
  25. prototype.toString = function toString(encoder) {
  26. var _encode = encoder ? function(value) {
  27. return encoder.call(this, value, encode);
  28. } : encode;
  29. return this._pairs.map(function each(pair) {
  30. return _encode(pair[0]) + '=' + _encode(pair[1]);
  31. }, '').join('&');
  32. };
  33. module.exports = AxiosURLSearchParams;