Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * Compiles a querystring
  3. * Returns string representation of the object
  4. *
  5. * @param {Object}
  6. * @api private
  7. */
  8. exports.encode = function (obj) {
  9. var str = '';
  10. for (var i in obj) {
  11. if (obj.hasOwnProperty(i)) {
  12. if (str.length) str += '&';
  13. str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);
  14. }
  15. }
  16. return str;
  17. };
  18. /**
  19. * Parses a simple querystring into an object
  20. *
  21. * @param {String} qs
  22. * @api private
  23. */
  24. exports.decode = function(qs){
  25. var qry = {};
  26. var pairs = qs.split('&');
  27. for (var i = 0, l = pairs.length; i < l; i++) {
  28. var pair = pairs[i].split('=');
  29. qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
  30. }
  31. return qry;
  32. };