"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.buildSortedURL = buildSortedURL;
exports.buildURLWithAxiosConfig = buildURLWithAxiosConfig;
exports.isCacheLike = isCacheLike;

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

var _buildURL = _interopRequireDefault(require("axios/lib/helpers/buildURL"));

function buildSortedURL() {
  var builtURL = _buildURL["default"].apply(void 0, arguments);

  var _builtURL$split = builtURL.split('?'),
      _builtURL$split2 = (0, _slicedToArray2["default"])(_builtURL$split, 2),
      urlPath = _builtURL$split2[0],
      queryString = _builtURL$split2[1];

  if (queryString) {
    var paramsPair = queryString.split('&');
    return "".concat(urlPath, "?").concat(paramsPair.sort().join('&'));
  }

  return builtURL;
}

function buildURLWithAxiosConfig(config) {
  var data = config.data,
      url = config.url,
      params = config.params,
      paramsSerializer = config.paramsSerializer;
  var builtURL = buildSortedURL(url, params, paramsSerializer);

  if (data) {
    return "".concat(builtURL, "|").concat(JSON.stringify(data));
  }

  return builtURL;
}

function isCacheLike(cache) {
  return !!(cache.set && cache.get && cache.del && typeof cache.get === 'function' && typeof cache.set === 'function' && typeof cache.del === 'function');
}
//# sourceMappingURL=utils.js.map
