@jsenv/snapshot 2.9.2 → 2.9.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/snapshot",
3
- "version": "2.9.2",
3
+ "version": "2.9.4",
4
4
  "description": "Snapshot testing",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -196,11 +196,24 @@ const replaceInObject = (object, { replace }) => {
196
196
  };
197
197
 
198
198
  const replaceHttpUrls = (source) => {
199
- source = source.replace(/(https?):\/\/localhost:\d+/g, (match, protocol) => {
200
- return `${protocol}://localhost`;
201
- });
202
- source = source.replace(/(https?):\/\/\[::1\]:\d+/g, (match, protocol) => {
203
- return `${protocol}://[::1]`;
199
+ source = source.replace(
200
+ /(https?):\/\/127.0.0.1(:\d+)?/g,
201
+ (match, protocol) => {
202
+ return `${protocol}://127.0.0.1`;
203
+ },
204
+ );
205
+ // we force "localhost" to "127.0.0.1"
206
+ // in case the machine does not have localhost mapping
207
+ source = source.replace(
208
+ /(https?):\/\/localhost(:\d+)?/g,
209
+ (match, protocol) => {
210
+ return `${protocol}://127.0.0.1`;
211
+ },
212
+ );
213
+ // we force [::1] to "127.0.0.1"
214
+ // in case the machine does not have ipv6
215
+ source = source.replace(/(https?):\/\/\[::1\](:\d+)?/g, (match, protocol) => {
216
+ return `${protocol}://127.0.0.1`;
204
217
  });
205
218
  return source;
206
219
  // return source.replace(/(?:https?|ftp):\/\/\S+[\w/]/g, (match) => {