|
3 | 3 | const util = require('util');
|
4 | 4 | const {
|
5 | 5 | hexTable,
|
6 |
| - isHexTable, |
7 |
| - StorageObject |
| 6 | + isHexTable |
8 | 7 | } = require('internal/querystring');
|
9 | 8 | const binding = process.binding('url');
|
10 | 9 | const context = Symbol('context');
|
@@ -97,6 +96,26 @@ class TupleOrigin {
|
97 | 96 | }
|
98 | 97 | }
|
99 | 98 |
|
| 99 | +// This class provides the internal state of a URL object. An instance of this |
| 100 | +// class is stored in every URL object and is accessed internally by setters |
| 101 | +// and getters. It roughly corresponds to the concept of a URL record in the |
| 102 | +// URL Standard, with a few differences. It is also the object transported to |
| 103 | +// the C++ binding. |
| 104 | +// Refs: https://url.spec.whatwg.org/#concept-url |
| 105 | +class URLContext { |
| 106 | + constructor() { |
| 107 | + this.flags = 0; |
| 108 | + this.scheme = undefined; |
| 109 | + this.username = undefined; |
| 110 | + this.password = undefined; |
| 111 | + this.host = undefined; |
| 112 | + this.port = undefined; |
| 113 | + this.path = []; |
| 114 | + this.query = undefined; |
| 115 | + this.fragment = undefined; |
| 116 | + } |
| 117 | +} |
| 118 | + |
100 | 119 | function onParseComplete(flags, protocol, username, password,
|
101 | 120 | host, port, path, query, fragment) {
|
102 | 121 | var ctx = this[context];
|
@@ -125,7 +144,7 @@ function onParseError(flags, input) {
|
125 | 144 | // Reused by URL constructor and URL#href setter.
|
126 | 145 | function parse(url, input, base) {
|
127 | 146 | const base_context = base ? base[context] : undefined;
|
128 |
| - url[context] = new StorageObject(); |
| 147 | + url[context] = new URLContext(); |
129 | 148 | binding.parse(input.trim(), -1,
|
130 | 149 | base_context, undefined,
|
131 | 150 | onParseComplete.bind(url), onParseError);
|
|
0 commit comments