diff options
author | Timothy Gu <timothygu99@gmail.com> | 2017-04-19 23:08:09 -0700 |
---|---|---|
committer | Timothy Gu <timothygu99@gmail.com> | 2017-04-24 16:42:59 -0700 |
commit | 061c5da010e0d249379618382a499840d38247b8 (patch) | |
tree | 183d020abc8a07ae97186b59c8fba1b13d7aff12 /lib | |
parent | 3c0dd45c882b8c84ec244d3a5635302fb4875d81 (diff) | |
download | android-node-v8-061c5da010e0d249379618382a499840d38247b8.tar.gz android-node-v8-061c5da010e0d249379618382a499840d38247b8.tar.bz2 android-node-v8-061c5da010e0d249379618382a499840d38247b8.zip |
url: use internal/util's getConstructorOf
PR-URL: https://github.com/nodejs/node/pull/12526
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/internal/url.js | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/lib/internal/url.js b/lib/internal/url.js index cacdff7c3a..25a4f51ba2 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -5,6 +5,7 @@ const { hexTable, isHexTable } = require('internal/querystring'); +const { getConstructorOf } = require('internal/util'); const binding = process.binding('url'); const context = Symbol('context'); const cannotBeBase = Symbol('cannot-be-base'); @@ -171,17 +172,6 @@ function onParseHashComplete(flags, protocol, username, password, this[context].fragment = fragment; } -function getEligibleConstructor(obj) { - while (obj !== null) { - if (Object.prototype.hasOwnProperty.call(obj, 'constructor') && - typeof obj.constructor === 'function') { - return obj.constructor; - } - obj = Object.getPrototypeOf(obj); - } - return null; -} - class URL { constructor(input, base) { // toUSVString is not needed. @@ -220,7 +210,7 @@ class URL { if (typeof depth === 'number' && depth < 0) return opts.stylize('[Object]', 'special'); - const ctor = getEligibleConstructor(this); + const ctor = getConstructorOf(this); const obj = Object.create({ constructor: ctor === null ? URL : ctor |