msw 0.36.8 → 0.38.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -465,6 +465,9 @@ var Headers_1$2 = Headers;
465
465
  function stringToHeaders(str) {
466
466
  var lines = str.trim().split(/[\r\n]+/);
467
467
  return lines.reduce(function (headers, line) {
468
+ if (line.trim() === '') {
469
+ return headers;
470
+ }
468
471
  var parts = line.split(': ');
469
472
  var name = parts.shift();
470
473
  var value = parts.join(': ');
@@ -656,7 +659,6 @@ var serialize_1 = serialize;
656
659
 
657
660
  var decode = decodeURIComponent;
658
661
  var encode = encodeURIComponent;
659
- var pairSplitRegExp = /; */;
660
662
 
661
663
  /**
662
664
  * RegExp to match field-content in RFC 7230 sec 3.2
@@ -687,28 +689,29 @@ function parse(str, options) {
687
689
 
688
690
  var obj = {};
689
691
  var opt = options || {};
690
- var pairs = str.split(pairSplitRegExp);
692
+ var pairs = str.split(';');
691
693
  var dec = opt.decode || decode;
692
694
 
693
695
  for (var i = 0; i < pairs.length; i++) {
694
696
  var pair = pairs[i];
695
- var eq_idx = pair.indexOf('=');
697
+ var index = pair.indexOf('=');
696
698
 
697
699
  // skip things that don't look like key=value
698
- if (eq_idx < 0) {
700
+ if (index < 0) {
699
701
  continue;
700
702
  }
701
703
 
702
- var key = pair.substr(0, eq_idx).trim();
703
- var val = pair.substr(++eq_idx, pair.length).trim();
704
-
705
- // quoted values
706
- if ('"' == val[0]) {
707
- val = val.slice(1, -1);
708
- }
704
+ var key = pair.substring(0, index).trim();
709
705
 
710
706
  // only assign once
711
707
  if (undefined == obj[key]) {
708
+ var val = pair.substring(index + 1, pair.length).trim();
709
+
710
+ // quoted values
711
+ if (val[0] === '"') {
712
+ val = val.slice(1, -1);
713
+ }
714
+
712
715
  obj[key] = tryDecode(val, dec);
713
716
  }
714
717
  }