| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0561c62 commit 6f580d5
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,7 @@ const { | |||
| 27 | 27 | ||
| 28 | 28 | const { compare } = internalBinding('buffer'); | |
| 29 | 29 | const assert = require('internal/assert'); | |
| 30 | + const { isURL } = require('internal/url'); | ||
| 30 | 31 | const types = require('internal/util/types'); | |
| 31 | 32 | const { | |
| 32 | 33 | isAnyArrayBuffer, | |
@@ -283,6 +284,10 @@ function innerDeepEqual(val1, val2, strict, memos) { | |||
| 283 | 284 | ) { | |
| 284 | 285 | return false; | |
| 285 | 286 | } | |
| 287 | + } else if (isURL(val1)) { | ||
| 288 | + if (!isURL(val2) || val1.href !== val2.href) { | ||
| 289 | + return false; | ||
| 290 | + } | ||
| 286 | 291 | } | |
| 287 | 292 | return keyCheck(val1, val2, strict, memos, kNoIterator); | |
| 288 | 293 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -170,6 +170,11 @@ function pathToFileUrlHref(filepath) { | |||
| 170 | 170 | return internalUrl.pathToFileURL(filepath).href; | |
| 171 | 171 | } | |
| 172 | 172 | ||
| 173 | + function isURL(value) { | ||
| 174 | + internalUrl ??= require('internal/url'); | ||
| 175 | + return typeof value.href === 'string' && value instanceof internalUrl.URL; | ||
| 176 | + } | ||
| 177 | + | ||
| 173 | 178 | const builtInObjects = new SafeSet( | |
| 174 | 179 | ArrayPrototypeFilter( | |
| 175 | 180 | ObjectGetOwnPropertyNames(globalThis), | |
@@ -1045,6 +1050,11 @@ function formatRaw(ctx, value, recurseTimes, typedArray) { | |||
| 1045 | 1050 | if (keys.length === 0 && protoProps === undefined) { | |
| 1046 | 1051 | return base; | |
| 1047 | 1052 | } | |
| 1053 | + } else if (isURL(value) && !(recurseTimes > ctx.depth && ctx.depth !== null)) { | ||
| 1054 | + base = value.href; | ||
| 1055 | + if (keys.length === 0 && protoProps === undefined) { | ||
| 1056 | + return base; | ||
| 1057 | + } | ||
| 1048 | 1058 | } else { | |
| 1049 | 1059 | if (keys.length === 0 && protoProps === undefined) { | |
| 1050 | 1060 | if (isExternal(value)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1318,3 +1318,47 @@ test('Crypto', { skip: !hasCrypto }, async () => { | |||
| 1318 | 1318 | assertDeepAndStrictEqual(a, b); | |
| 1319 | 1319 | } | |
| 1320 | 1320 | }); | |
| 1321 | + | ||
| 1322 | + // check URL | ||
| 1323 | + { | ||
| 1324 | + const a = new URL('http://foo'); | ||
| 1325 | + const b = new URL('http://bar'); | ||
| 1326 | + | ||
| 1327 | + assertNotDeepOrStrict(a, b); | ||
| 1328 | + } | ||
| 1329 | + | ||
| 1330 | + { | ||
| 1331 | + const a = new URL('http://foo'); | ||
| 1332 | + const b = new URL('http://foo'); | ||
| 1333 | + | ||
| 1334 | + assertDeepAndStrictEqual(a, b); | ||
| 1335 | + } | ||
| 1336 | + | ||
| 1337 | + { | ||
| 1338 | + const a = new URL('http://foo'); | ||
| 1339 | + const b = new URL('http://foo'); | ||
| 1340 | + a.bar = 1; | ||
| 1341 | + b.bar = 2; | ||
| 1342 | + assertNotDeepOrStrict(a, b); | ||
| 1343 | + } | ||
| 1344 | + | ||
| 1345 | + { | ||
| 1346 | + const a = new URL('http://foo'); | ||
| 1347 | + const b = new URL('http://foo'); | ||
| 1348 | + a.bar = 1; | ||
| 1349 | + b.bar = 1; | ||
| 1350 | + assertDeepAndStrictEqual(a, b); | ||
| 1351 | + } | ||
| 1352 | + | ||
| 1353 | + { | ||
| 1354 | + const a = new URL('http://foo'); | ||
| 1355 | + const b = new URL('http://bar'); | ||
| 1356 | + assert.throws( | ||
| 1357 | + () => assert.deepStrictEqual(a, b), | ||
| 1358 | + { | ||
| 1359 | + code: 'ERR_ASSERTION', | ||
| 1360 | + name: 'AssertionError', | ||
| 1361 | + message: /http:\/\/bar/ | ||
| 1362 | + } | ||
| 1363 | + ); | ||
| 1364 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments