33const util = require ( 'util' ) ;
44const {
55 hexTable,
6- isHexTable,
7- StorageObject
6+ isHexTable
87} = require ( 'internal/querystring' ) ;
98const binding = process . binding ( 'url' ) ;
109const context = Symbol ( 'context' ) ;
@@ -97,6 +96,26 @@ class TupleOrigin {
9796 }
9897}
9998
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+
100119function onParseComplete ( flags , protocol , username , password ,
101120 host , port , path , query , fragment ) {
102121 if ( flags & binding . URL_FLAGS_FAILED )
@@ -121,7 +140,7 @@ function onParseComplete(flags, protocol, username, password,
121140// Reused by URL constructor and URL#href setter.
122141function parse ( url , input , base ) {
123142 const base_context = base ? base [ context ] : undefined ;
124- url [ context ] = new StorageObject ( ) ;
143+ url [ context ] = new URLContext ( ) ;
125144 binding . parse ( input . trim ( ) , - 1 ,
126145 base_context , undefined ,
127146 onParseComplete . bind ( url ) ) ;
0 commit comments