| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a11507e commit 1b06c1e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -692,11 +692,14 @@ ObjectDefineProperties(URLSearchParams.prototype, { | |||
| 692 | 692 | * | |
| 693 | 693 | * We use `href` and `protocol` as they are the only properties that are | |
| 694 | 694 | * easy to retrieve and calculate due to the lazy nature of the getters. | |
| 695 | + * | ||
| 696 | + * We check for auth attribute to distinguish legacy url instance with | ||
| 697 | + * WHATWG URL instance. | ||
| 695 | 698 | * @param {*} self | |
| 696 | 699 | * @returns {self is URL} | |
| 697 | 700 | */ | |
| 698 | 701 | function isURL(self) { | |
| 699 | - return Boolean(self?.href && self.protocol); | ||
| 702 | + return Boolean(self?.href && self.protocol && self.auth === undefined); | ||
| 700 | 703 | } | |
| 701 | 704 | ||
| 702 | 705 | class URL { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,11 @@ | |||
| 1 | + // Flags: --expose-internals | ||
| 2 | + 'use strict'; | ||
| 3 | + | ||
| 4 | + require('../common'); | ||
| 5 | + | ||
| 6 | + const { URL, parse } = require('url'); | ||
| 7 | + const assert = require('assert'); | ||
| 8 | + const { isURL } = require('internal/url'); | ||
| 9 | + | ||
| 10 | + assert.strictEqual(isURL(new URL('https://www.nodejs.org')), true); | ||
| 11 | + assert.strictEqual(isURL(parse('https://www.nodejs.org')), false); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments