rollbar 2.26.2 → 2.26.4

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.
Files changed (117) hide show
  1. package/.github/workflows/ci.yml +32 -10
  2. package/.lgtm.yml +7 -7
  3. package/.prettierignore +18 -0
  4. package/.vscode/settings.json +39 -0
  5. package/CHANGELOG.md +121 -35
  6. package/Gruntfile.js +51 -71
  7. package/README.md +2 -4
  8. package/bower.json +1 -3
  9. package/defaults.js +17 -5
  10. package/dist/plugins/jquery.min.js +1 -1
  11. package/dist/rollbar.js +5699 -5052
  12. package/dist/rollbar.js.map +1 -1
  13. package/dist/rollbar.min.js +1 -1
  14. package/dist/rollbar.min.js.map +1 -1
  15. package/dist/rollbar.named-amd.js +5704 -5062
  16. package/dist/rollbar.named-amd.js.map +1 -1
  17. package/dist/rollbar.named-amd.min.js +1 -1
  18. package/dist/rollbar.named-amd.min.js.map +1 -1
  19. package/dist/rollbar.noconflict.umd.js +5693 -5052
  20. package/dist/rollbar.noconflict.umd.js.map +1 -1
  21. package/dist/rollbar.noconflict.umd.min.js +1 -1
  22. package/dist/rollbar.noconflict.umd.min.js.map +1 -1
  23. package/dist/rollbar.snippet.js +1 -1
  24. package/dist/rollbar.umd.js +5704 -5063
  25. package/dist/rollbar.umd.js.map +1 -1
  26. package/dist/rollbar.umd.min.js +1 -1
  27. package/dist/rollbar.umd.min.js.map +1 -1
  28. package/docs/extension-exceptions.md +35 -30
  29. package/docs/migration_v0_to_v1.md +41 -38
  30. package/index.d.ts +270 -231
  31. package/karma.conf.js +16 -34
  32. package/package.json +21 -17
  33. package/prettier.config.js +7 -0
  34. package/src/api.js +21 -10
  35. package/src/apiUtility.js +12 -8
  36. package/src/browser/core.js +103 -65
  37. package/src/browser/defaults/scrubFields.js +3 -3
  38. package/src/browser/detection.js +7 -8
  39. package/src/browser/domUtility.js +18 -8
  40. package/src/browser/globalSetup.js +12 -6
  41. package/src/browser/logger.js +1 -1
  42. package/src/browser/plugins/jquery.js +35 -35
  43. package/src/browser/predicates.js +1 -1
  44. package/src/browser/rollbar.js +1 -1
  45. package/src/browser/rollbarWrapper.js +8 -5
  46. package/src/browser/shim.js +43 -19
  47. package/src/browser/snippet_callback.js +6 -4
  48. package/src/browser/telemetry.js +573 -354
  49. package/src/browser/transforms.js +46 -27
  50. package/src/browser/transport/fetch.js +16 -14
  51. package/src/browser/transport/xhr.js +29 -13
  52. package/src/browser/transport.js +82 -25
  53. package/src/browser/url.js +16 -8
  54. package/src/browser/wrapGlobals.js +27 -8
  55. package/src/defaults.js +3 -3
  56. package/src/errorParser.js +14 -11
  57. package/src/merge.js +32 -23
  58. package/src/notifier.js +16 -13
  59. package/src/predicates.js +43 -23
  60. package/src/queue.js +71 -39
  61. package/src/rateLimiter.js +59 -18
  62. package/src/react-native/logger.js +1 -1
  63. package/src/react-native/rollbar.js +59 -55
  64. package/src/react-native/transforms.js +13 -9
  65. package/src/react-native/transport.js +44 -34
  66. package/src/rollbar.js +22 -13
  67. package/src/scrub.js +0 -1
  68. package/src/server/locals.js +69 -39
  69. package/src/server/logger.js +4 -4
  70. package/src/server/parser.js +72 -47
  71. package/src/server/rollbar.js +133 -55
  72. package/src/server/sourceMap/stackTrace.js +33 -18
  73. package/src/server/telemetry/urlHelpers.js +9 -11
  74. package/src/server/telemetry.js +68 -45
  75. package/src/server/transforms.js +37 -21
  76. package/src/server/transport.js +62 -32
  77. package/src/telemetry.js +92 -28
  78. package/src/transforms.js +33 -21
  79. package/src/truncation.js +8 -5
  80. package/src/utility/headers.js +43 -43
  81. package/src/utility/replace.js +9 -0
  82. package/src/utility/traverse.js +1 -1
  83. package/src/utility.js +89 -52
  84. package/test/api.test.js +31 -29
  85. package/test/apiUtility.test.js +43 -44
  86. package/test/browser.core.test.js +141 -131
  87. package/test/browser.domUtility.test.js +52 -35
  88. package/test/browser.predicates.test.js +13 -13
  89. package/test/browser.rollbar.test.js +597 -503
  90. package/test/browser.telemetry.test.js +76 -0
  91. package/test/browser.transforms.test.js +146 -128
  92. package/test/browser.transport.test.js +54 -46
  93. package/test/browser.url.test.js +12 -11
  94. package/test/fixtures/locals.fixtures.js +245 -126
  95. package/test/notifier.test.js +90 -78
  96. package/test/predicates.test.js +260 -214
  97. package/test/queue.test.js +230 -214
  98. package/test/rateLimiter.test.js +50 -42
  99. package/test/react-native.rollbar.test.js +149 -115
  100. package/test/react-native.transforms.test.js +21 -23
  101. package/test/react-native.transport.test.js +23 -11
  102. package/test/server.lambda.test.js +70 -53
  103. package/test/server.locals.test.js +437 -210
  104. package/test/server.parser.test.js +32 -26
  105. package/test/server.predicates.test.js +45 -43
  106. package/test/server.rollbar.test.js +311 -259
  107. package/test/server.telemetry.test.js +208 -83
  108. package/test/server.transforms.test.js +455 -361
  109. package/test/server.transport.test.js +144 -76
  110. package/test/telemetry.test.js +46 -37
  111. package/test/transforms.test.js +68 -66
  112. package/test/truncation.test.js +55 -53
  113. package/test/utility.test.js +266 -222
  114. package/webpack.config.js +46 -43
  115. package/.gitmodules +0 -3
  116. package/browserstack.browsers.js +0 -153
  117. package/browserstack.browsers.json +0 -4384
@@ -39,9 +39,14 @@ function Rollbar(options, client) {
39
39
  this.lambdaTimeoutHandle = null;
40
40
  var transport = new Transport();
41
41
  var api = new API(this.options, transport, urllib, truncation, jsonBackup);
42
- var telemeter = new Telemeter(this.options)
43
- this.client = client || new Client(this.options, api, logger, telemeter, 'server');
44
- this.instrumenter = new Instrumenter(this.options, this.client.telemeter, this);
42
+ var telemeter = new Telemeter(this.options);
43
+ this.client =
44
+ client || new Client(this.options, api, logger, telemeter, 'server');
45
+ this.instrumenter = new Instrumenter(
46
+ this.options,
47
+ this.client.telemeter,
48
+ this,
49
+ );
45
50
  this.instrumenter.instrument();
46
51
  if (this.options.locals) {
47
52
  this.locals = initLocals(this.options.locals, logger);
@@ -55,7 +60,9 @@ function Rollbar(options, client) {
55
60
  function initLocals(localsOptions, logger) {
56
61
  // Capturing stack local variables is only supported in Node 10 and higher.
57
62
  var nodeMajorVersion = process.versions.node.split('.')[0];
58
- if (nodeMajorVersion < 10) { return null; }
63
+ if (nodeMajorVersion < 10) {
64
+ return null;
65
+ }
59
66
 
60
67
  var Locals;
61
68
  if (typeof localsOptions === 'function') {
@@ -65,7 +72,9 @@ function initLocals(localsOptions, logger) {
65
72
  Locals = localsOptions.module;
66
73
  delete localsOptions.module;
67
74
  } else {
68
- logger.error('options.locals or options.locals.module must be a Locals module');
75
+ logger.error(
76
+ 'options.locals or options.locals.module must be a Locals module',
77
+ );
69
78
  return null;
70
79
  }
71
80
  return new Locals(localsOptions, logger);
@@ -110,7 +119,11 @@ Rollbar.prototype.configure = function (options, payloadData) {
110
119
  payload = { payload: payloadData };
111
120
  }
112
121
  this.options = _.handleOptions(oldOptions, options, payload, logger);
113
- this.options._configuredOptions = _.handleOptions(oldOptions._configuredOptions, options, payload);
122
+ this.options._configuredOptions = _.handleOptions(
123
+ oldOptions._configuredOptions,
124
+ options,
125
+ payload,
126
+ );
114
127
  // On the server we want to ignore any maxItems setting
115
128
  delete this.options.maxItems;
116
129
  logger.setVerbose(this.options.verbose);
@@ -121,7 +134,7 @@ Rollbar.prototype.configure = function (options, payloadData) {
121
134
  if (this.locals) {
122
135
  this.locals.updateOptions(this.options.locals);
123
136
  } else {
124
- this.locals = initLocals(this.options.locals, logger)
137
+ this.locals = initLocals(this.options.locals, logger);
125
138
  }
126
139
  }
127
140
  return this;
@@ -205,7 +218,6 @@ Rollbar.warn = function () {
205
218
  }
206
219
  };
207
220
 
208
-
209
221
  Rollbar.prototype.warning = function () {
210
222
  var item = this._createItem(arguments);
211
223
  var uuid = item.uuid;
@@ -221,7 +233,6 @@ Rollbar.warning = function () {
221
233
  }
222
234
  };
223
235
 
224
-
225
236
  Rollbar.prototype.error = function () {
226
237
  var item = this._createItem(arguments);
227
238
  var uuid = item.uuid;
@@ -286,7 +297,7 @@ Rollbar.prototype.wait = function (callback) {
286
297
  };
287
298
  Rollbar.wait = function (callback) {
288
299
  if (_instance) {
289
- return _instance.wait(callback)
300
+ return _instance.wait(callback);
290
301
  } else {
291
302
  var maybeCallback = _getFirstFunction(arguments);
292
303
  handleUninitialized(maybeCallback);
@@ -313,7 +324,7 @@ Rollbar.prototype.errorHandler = function () {
313
324
  };
314
325
  Rollbar.errorHandler = function () {
315
326
  if (_instance) {
316
- return _instance.errorHandler()
327
+ return _instance.errorHandler();
317
328
  } else {
318
329
  handleUninitialized();
319
330
  }
@@ -341,8 +352,15 @@ Rollbar.prototype.asyncLambdaHandler = function (handler, timeoutHandler) {
341
352
  return new Promise(function (resolve, reject) {
342
353
  self.lambdaContext = context;
343
354
  if (shouldReportTimeouts) {
344
- var timeoutCb = (timeoutHandler || _timeoutHandler).bind(null, event, context);
345
- self.lambdaTimeoutHandle = setTimeout(timeoutCb, context.getRemainingTimeInMillis() - 1000);
355
+ var timeoutCb = (timeoutHandler || _timeoutHandler).bind(
356
+ null,
357
+ event,
358
+ context,
359
+ );
360
+ self.lambdaTimeoutHandle = setTimeout(
361
+ timeoutCb,
362
+ context.getRemainingTimeInMillis() - 1000,
363
+ );
346
364
  }
347
365
  handler(event, context)
348
366
  .then(function (resp) {
@@ -375,8 +393,16 @@ Rollbar.prototype.syncLambdaHandler = function (handler, timeoutHandler) {
375
393
  return function (event, context, callback) {
376
394
  self.lambdaContext = context;
377
395
  if (shouldReportTimeouts) {
378
- var timeoutCb = (timeoutHandler || _timeoutHandler).bind(null, event, context, callback);
379
- self.lambdaTimeoutHandle = setTimeout(timeoutCb, context.getRemainingTimeInMillis() - 1000);
396
+ var timeoutCb = (timeoutHandler || _timeoutHandler).bind(
397
+ null,
398
+ event,
399
+ context,
400
+ callback,
401
+ );
402
+ self.lambdaTimeoutHandle = setTimeout(
403
+ timeoutCb,
404
+ context.getRemainingTimeInMillis() - 1000,
405
+ );
380
406
  }
381
407
  try {
382
408
  handler(event, context, function (err, resp) {
@@ -456,19 +482,33 @@ Rollbar.reportMessage = function (message, level, request, callback) {
456
482
  }
457
483
  };
458
484
 
459
- Rollbar.prototype.reportMessageWithPayloadData = function (message, payloadData, request, callback) {
485
+ Rollbar.prototype.reportMessageWithPayloadData = function (
486
+ message,
487
+ payloadData,
488
+ request,
489
+ callback,
490
+ ) {
460
491
  logger.log('reportMessageWithPayloadData is deprecated');
461
492
  return this.error(message, request, payloadData, callback);
462
493
  };
463
- Rollbar.reportMessageWithPayloadData = function (message, payloadData, request, callback) {
494
+ Rollbar.reportMessageWithPayloadData = function (
495
+ message,
496
+ payloadData,
497
+ request,
498
+ callback,
499
+ ) {
464
500
  if (_instance) {
465
- return _instance.reportMessageWithPayloadData(message, payloadData, request, callback);
501
+ return _instance.reportMessageWithPayloadData(
502
+ message,
503
+ payloadData,
504
+ request,
505
+ callback,
506
+ );
466
507
  } else {
467
508
  handleUninitialized(callback);
468
509
  }
469
510
  };
470
511
 
471
-
472
512
  Rollbar.prototype.handleError = function (err, request, callback) {
473
513
  logger.log('handleError is deprecated');
474
514
  return this.error(err, request, callback);
@@ -481,14 +521,28 @@ Rollbar.handleError = function (err, request, callback) {
481
521
  }
482
522
  };
483
523
 
484
-
485
- Rollbar.prototype.handleErrorWithPayloadData = function (err, payloadData, request, callback) {
524
+ Rollbar.prototype.handleErrorWithPayloadData = function (
525
+ err,
526
+ payloadData,
527
+ request,
528
+ callback,
529
+ ) {
486
530
  logger.log('handleErrorWithPayloadData is deprecated');
487
531
  return this.error(err, request, payloadData, callback);
488
532
  };
489
- Rollbar.handleErrorWithPayloadData = function (err, payloadData, request, callback) {
533
+ Rollbar.handleErrorWithPayloadData = function (
534
+ err,
535
+ payloadData,
536
+ request,
537
+ callback,
538
+ ) {
490
539
  if (_instance) {
491
- return _instance.handleErrorWithPayloadData(err, payloadData, request, callback);
540
+ return _instance.handleErrorWithPayloadData(
541
+ err,
542
+ payloadData,
543
+ request,
544
+ callback,
545
+ );
492
546
  } else {
493
547
  handleUninitialized(callback);
494
548
  }
@@ -514,7 +568,10 @@ Rollbar.handleUnhandledRejections = function (accessToken, options) {
514
568
  }
515
569
  };
516
570
 
517
- Rollbar.handleUncaughtExceptionsAndRejections = function (accessToken, options) {
571
+ Rollbar.handleUncaughtExceptionsAndRejections = function (
572
+ accessToken,
573
+ options,
574
+ ) {
518
575
  if (_instance) {
519
576
  options = options || {};
520
577
  options.accessToken = accessToken;
@@ -577,7 +634,10 @@ Rollbar.prototype.setupUnhandledCapture = function () {
577
634
  if (this.options.captureUncaught || this.options.handleUncaughtExceptions) {
578
635
  this.handleUncaughtExceptions();
579
636
  }
580
- if (this.options.captureUnhandledRejections || this.options.handleUnhandledRejections) {
637
+ if (
638
+ this.options.captureUnhandledRejections ||
639
+ this.options.handleUnhandledRejections
640
+ ) {
581
641
  this.handleUnhandledRejections();
582
642
  }
583
643
  };
@@ -586,40 +646,58 @@ Rollbar.prototype.handleUncaughtExceptions = function () {
586
646
  var exitOnUncaught = !!this.options.exitOnUncaughtException;
587
647
  delete this.options.exitOnUncaughtException;
588
648
 
589
- addOrReplaceRollbarHandler('uncaughtException', function (err) {
590
- if (!this.options.captureUncaught && !this.options.handleUncaughtExceptions) {
591
- return;
592
- }
649
+ addOrReplaceRollbarHandler(
650
+ 'uncaughtException',
651
+ function (err) {
652
+ if (
653
+ !this.options.captureUncaught &&
654
+ !this.options.handleUncaughtExceptions
655
+ ) {
656
+ return;
657
+ }
593
658
 
594
- this._uncaughtError(err, function (err) {
595
- if (err) {
596
- logger.error('Encountered error while handling an uncaught exception.');
597
- logger.error(err);
659
+ this._uncaughtError(err, function (err) {
660
+ if (err) {
661
+ logger.error(
662
+ 'Encountered error while handling an uncaught exception.',
663
+ );
664
+ logger.error(err);
665
+ }
666
+ });
667
+ if (exitOnUncaught) {
668
+ setImmediate(
669
+ function () {
670
+ this.wait(function () {
671
+ process.exit(1);
672
+ });
673
+ }.bind(this),
674
+ );
598
675
  }
599
- });
600
- if (exitOnUncaught) {
601
- setImmediate(function () {
602
- this.wait(function () {
603
- process.exit(1);
604
- });
605
- }.bind(this));
606
- }
607
- }.bind(this));
676
+ }.bind(this),
677
+ );
608
678
  };
609
679
 
610
680
  Rollbar.prototype.handleUnhandledRejections = function () {
611
- addOrReplaceRollbarHandler('unhandledRejection', function (reason) {
612
- if (!this.options.captureUnhandledRejections && !this.options.handleUnhandledRejections) {
613
- return;
614
- }
615
-
616
- this._uncaughtError(reason, function (err) {
617
- if (err) {
618
- logger.error('Encountered error while handling an uncaught exception.');
619
- logger.error(err);
681
+ addOrReplaceRollbarHandler(
682
+ 'unhandledRejection',
683
+ function (reason) {
684
+ if (
685
+ !this.options.captureUnhandledRejections &&
686
+ !this.options.handleUnhandledRejections
687
+ ) {
688
+ return;
620
689
  }
621
- });
622
- }.bind(this));
690
+
691
+ this._uncaughtError(reason, function (err) {
692
+ if (err) {
693
+ logger.error(
694
+ 'Encountered error while handling an uncaught exception.',
695
+ );
696
+ logger.error(err);
697
+ }
698
+ });
699
+ }.bind(this),
700
+ );
623
701
  };
624
702
 
625
703
  function addOrReplaceRollbarHandler(event, action) {
@@ -658,7 +736,7 @@ Rollbar.defaultOptions = {
658
736
  showReportedMessageTraces: false,
659
737
  notifier: {
660
738
  name: 'node_rollbar',
661
- version: packageJson.version
739
+ version: packageJson.version,
662
740
  },
663
741
  scrubHeaders: packageJson.defaults.server.scrubHeaders,
664
742
  scrubFields: packageJson.defaults.server.scrubFields,
@@ -675,7 +753,7 @@ Rollbar.defaultOptions = {
675
753
  captureLambdaTimeouts: true,
676
754
  ignoreDuplicateErrors: true,
677
755
  scrubRequestBody: true,
678
- autoInstrument: false
756
+ autoInstrument: false,
679
757
  };
680
758
 
681
759
  module.exports = Rollbar;
@@ -31,10 +31,10 @@ function retrieveFile(path) {
31
31
  path = path.trim();
32
32
  if (/^file:/.test(path)) {
33
33
  // existsSync/readFileSync can't handle file protocol, but once stripped, it works
34
- path = path.replace(/file:\/\/\/(\w:)?/, function(_protocol, drive) {
35
- return drive ?
36
- '' : // file:///C:/dir/file -> C:/dir/file
37
- '/'; // file:///root-dir/file -> /root-dir/file
34
+ path = path.replace(/file:\/\/\/(\w:)?/, function (_protocol, drive) {
35
+ return drive
36
+ ? '' // file:///C:/dir/file -> C:/dir/file
37
+ : '/'; // file:///root-dir/file -> /root-dir/file
38
38
  });
39
39
  }
40
40
  if (path in fileContentsCache) {
@@ -50,7 +50,7 @@ function retrieveFile(path) {
50
50
  /* ignore any errors */
51
51
  }
52
52
 
53
- return fileContentsCache[path] = contents;
53
+ return (fileContentsCache[path] = contents);
54
54
  }
55
55
 
56
56
  // Support URLs relative to a directory, but be careful about a protocol prefix
@@ -64,7 +64,10 @@ function supportRelativeURL(file, url) {
64
64
  if (protocol && /^\/\w\:/.test(startPath)) {
65
65
  // handle file:///C:/ paths
66
66
  protocol += '/';
67
- return protocol + path.resolve(dir.slice(protocol.length), url).replace(/\\/g, '/');
67
+ return (
68
+ protocol +
69
+ path.resolve(dir.slice(protocol.length), url).replace(/\\/g, '/')
70
+ );
68
71
  }
69
72
  return protocol + path.resolve(dir.slice(protocol.length), url);
70
73
  }
@@ -74,7 +77,8 @@ function retrieveSourceMapURL(source) {
74
77
 
75
78
  // Get the URL of the source map
76
79
  fileData = retrieveFile(source);
77
- var re = /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/)[ \t]*$)/mg;
80
+ var re =
81
+ /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/)[ \t]*$)/gm;
78
82
  // Keep executing the search to find the *last* sourceMappingURL to avoid
79
83
  // picking up sourceMappingURLs from comments, strings, etc.
80
84
  var lastMatch, match;
@@ -110,7 +114,7 @@ function retrieveSourceMap(source) {
110
114
 
111
115
  return {
112
116
  url: sourceMappingURL,
113
- map: sourceMapData
117
+ map: sourceMapData,
114
118
  };
115
119
  }
116
120
 
@@ -122,7 +126,10 @@ function cacheSourceContent(sourceMap, originalSource, newSource) {
122
126
  // The sourceContentFor lookup needs the original source url as found in the
123
127
  // map file. However the client lookup in sourcesContentCache will use
124
128
  // a rewritten form of the url, hence originalSource and newSource.
125
- sourcesContentCache[newSource] = sourceMap.map.sourceContentFor(originalSource, true);
129
+ sourcesContentCache[newSource] = sourceMap.map.sourceContentFor(
130
+ originalSource,
131
+ true,
132
+ );
126
133
  }
127
134
 
128
135
  exports.mapSourcePosition = function mapSourcePosition(position, diagnostic) {
@@ -133,14 +140,15 @@ exports.mapSourcePosition = function mapSourcePosition(position, diagnostic) {
133
140
  if (urlAndMap) {
134
141
  sourceMap = sourceMapCache[position.source] = {
135
142
  url: urlAndMap.url,
136
- map: new SourceMapConsumer(urlAndMap.map)
143
+ map: new SourceMapConsumer(urlAndMap.map),
137
144
  };
138
- diagnostic.node_source_maps.source_mapping_urls[position.source] = urlAndMap.url;
145
+ diagnostic.node_source_maps.source_mapping_urls[position.source] =
146
+ urlAndMap.url;
139
147
 
140
148
  // Load all sources stored inline with the source map into the file cache
141
149
  // to pretend like they are already loaded. They may not exist on disk.
142
150
  if (sourceMap.map.sourcesContent) {
143
- sourceMap.map.sources.forEach(function(source, i) {
151
+ sourceMap.map.sources.forEach(function (source, i) {
144
152
  var contents = sourceMap.map.sourcesContent[i];
145
153
  if (contents) {
146
154
  var url = supportRelativeURL(sourceMap.url, source);
@@ -151,14 +159,19 @@ exports.mapSourcePosition = function mapSourcePosition(position, diagnostic) {
151
159
  } else {
152
160
  sourceMap = sourceMapCache[position.source] = {
153
161
  url: null,
154
- map: null
162
+ map: null,
155
163
  };
156
- diagnostic.node_source_maps.source_mapping_urls[position.source] = 'not found';
164
+ diagnostic.node_source_maps.source_mapping_urls[position.source] =
165
+ 'not found';
157
166
  }
158
167
  }
159
168
 
160
169
  // Resolve the source URL relative to the URL of the source map
161
- if (sourceMap && sourceMap.map && typeof sourceMap.map.originalPositionFor === 'function') {
170
+ if (
171
+ sourceMap &&
172
+ sourceMap.map &&
173
+ typeof sourceMap.map.originalPositionFor === 'function'
174
+ ) {
162
175
  var originalPosition = sourceMap.map.originalPositionFor(position);
163
176
 
164
177
  // Only return the original position if a matching line was found. If no
@@ -169,15 +182,17 @@ exports.mapSourcePosition = function mapSourcePosition(position, diagnostic) {
169
182
  if (originalPosition.source !== null) {
170
183
  var originalSource = originalPosition.source;
171
184
  originalPosition.source = supportRelativeURL(
172
- sourceMap.url, originalPosition.source);
185
+ sourceMap.url,
186
+ originalPosition.source,
187
+ );
173
188
  cacheSourceContent(sourceMap, originalSource, originalPosition.source);
174
189
  return originalPosition;
175
190
  }
176
191
  }
177
192
 
178
193
  return position;
179
- }
194
+ };
180
195
 
181
196
  exports.sourceContent = function sourceContent(source) {
182
197
  return sourcesContentCache[source];
183
- }
198
+ };
@@ -1,4 +1,3 @@
1
- var url = require('url');
2
1
  var { URL } = require('url');
3
2
  var merge = require('../../merge');
4
3
 
@@ -12,8 +11,7 @@ function mergeOptions(input, options, cb) {
12
11
  if (typeof input === 'string') {
13
12
  const urlStr = input;
14
13
  input = urlToHttpOptions(new URL(urlStr));
15
- } else if (input && input[url.searchParamsSymbol] &&
16
- input[url.searchParamsSymbol][url.searchParamsSymbol]) {
14
+ } else if (input && input instanceof URL) {
17
15
  // url.URL instance
18
16
  input = urlToHttpOptions(input);
19
17
  } else {
@@ -28,7 +26,7 @@ function mergeOptions(input, options, cb) {
28
26
  } else {
29
27
  options = merge(input || {}, options);
30
28
  }
31
- return {options: options, cb: cb};
29
+ return { options: options, cb: cb };
32
30
  }
33
31
 
34
32
  // This function replicates the relevant logic in node/lib/url.js as closely
@@ -40,15 +38,15 @@ function mergeOptions(input, options, cb) {
40
38
  function urlToHttpOptions(url) {
41
39
  const options = {
42
40
  protocol: url.protocol,
43
- hostname: typeof url.hostname === 'string' &&
44
- url.hostname.startsWith('[') ?
45
- url.hostname.slice(1, -1) :
46
- url.hostname,
41
+ hostname:
42
+ typeof url.hostname === 'string' && url.hostname.startsWith('[')
43
+ ? url.hostname.slice(1, -1)
44
+ : url.hostname,
47
45
  hash: url.hash,
48
46
  search: url.search,
49
47
  pathname: url.pathname,
50
48
  path: `${url.pathname || ''}${url.search || ''}`,
51
- href: url.href
49
+ href: url.href,
52
50
  };
53
51
  if (url.port !== '') {
54
52
  options.port = Number(url.port);
@@ -67,7 +65,7 @@ function constructUrl(options) {
67
65
  }
68
66
  url += options.hostname || options.host || 'localhost';
69
67
  if (options.port) {
70
- url += `:${options.port}`
68
+ url += `:${options.port}`;
71
69
  }
72
70
  url += options.path || '/';
73
71
 
@@ -76,5 +74,5 @@ function constructUrl(options) {
76
74
 
77
75
  module.exports = {
78
76
  mergeOptions,
79
- constructUrl
77
+ constructUrl,
80
78
  };