12345678910111213141516171819202122232425262728293031 |
- "use strict";
- require("../common/vendor.js");
- const urlEncode = (obj = {}) => {
- const result = [];
- for (const key in obj) {
- const item = obj[key];
- if (!item) {
- continue;
- }
- if (isArray(item)) {
- item.forEach((val) => {
- result.push(key + "=" + val);
- });
- } else {
- result.push(key + "=" + item);
- }
- }
- return result.join("&");
- };
- const inArray = (search, array) => {
- for (var i in array) {
- if (array[i] == search)
- return true;
- }
- return false;
- };
- const isArray = (array) => {
- return Object.prototype.toString.call(array) === "[object Array]";
- };
- exports.inArray = inArray;
- exports.urlEncode = urlEncode;
|