Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
/**
 * If the response contains 'set-cookie' headers, this method duplicates them so that they are also set on the
 * local proxying domain. The local domain is localhost by default.
 * @param {string} localDomain The domain in which to set the cookies
 * @param {Response} response The response coming from the proxied endpoint
 */
var extendSetCookieHeadersForLocalDomain = exports.extendSetCookieHeadersForLocalDomain = function extendSetCookieHeadersForLocalDomain() {
  var localDomain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'localhost';
  var response = arguments[1];

  var cookieSetterHeaders = response.headers['set-cookie'];

  if (Array.isArray(cookieSetterHeaders)) {
    // If not on localhost, prepend the domain with the `.` so it works on subdomains too
    var overriddenDomain = localDomain === 'localhost' ? localDomain : '.' + localDomain;

    cookieSetterHeaders.forEach(function (header) {
      var cookieForLocalhost = header.replace(/Domain=.+?;/, 'Domain=' + overriddenDomain + ';');
      cookieSetterHeaders.push(cookieForLocalhost);
    });
  }
};