@@ -99,8 +99,6 @@ class TupleOrigin {
9999
100100function onParseComplete ( flags , protocol , username , password ,
101101 host , port , path , query , fragment ) {
102- if ( flags & binding . URL_FLAGS_FAILED )
103- throw new TypeError ( 'Invalid URL' ) ;
104102 var ctx = this [ context ] ;
105103 ctx . flags = flags ;
106104 ctx . scheme = protocol ;
@@ -118,19 +116,23 @@ function onParseComplete(flags, protocol, username, password,
118116 initSearchParams ( this [ searchParams ] , query ) ;
119117}
120118
119+ function onParseError ( flags , input ) {
120+ const error = new TypeError ( 'Invalid URL: ' + input ) ;
121+ error . input = input ;
122+ throw error ;
123+ }
124+
121125// Reused by URL constructor and URL#href setter.
122126function parse ( url , input , base ) {
123127 const base_context = base ? base [ context ] : undefined ;
124128 url [ context ] = new StorageObject ( ) ;
125129 binding . parse ( input . trim ( ) , - 1 ,
126130 base_context , undefined ,
127- onParseComplete . bind ( url ) ) ;
131+ onParseComplete . bind ( url ) , onParseError ) ;
128132}
129133
130134function onParseProtocolComplete ( flags , protocol , username , password ,
131135 host , port , path , query , fragment ) {
132- if ( flags & binding . URL_FLAGS_FAILED )
133- return ;
134136 const newIsSpecial = ( flags & binding . URL_FLAGS_SPECIAL ) !== 0 ;
135137 const s = this [ special ] ;
136138 const ctx = this [ context ] ;
@@ -159,8 +161,6 @@ function onParseProtocolComplete(flags, protocol, username, password,
159161
160162function onParseHostComplete ( flags , protocol , username , password ,
161163 host , port , path , query , fragment ) {
162- if ( flags & binding . URL_FLAGS_FAILED )
163- return ;
164164 const ctx = this [ context ] ;
165165 if ( host ) {
166166 ctx . host = host ;
@@ -174,8 +174,6 @@ function onParseHostComplete(flags, protocol, username, password,
174174
175175function onParseHostnameComplete ( flags , protocol , username , password ,
176176 host , port , path , query , fragment ) {
177- if ( flags & binding . URL_FLAGS_FAILED )
178- return ;
179177 const ctx = this [ context ] ;
180178 if ( host ) {
181179 ctx . host = host ;
@@ -187,15 +185,11 @@ function onParseHostnameComplete(flags, protocol, username, password,
187185
188186function onParsePortComplete ( flags , protocol , username , password ,
189187 host , port , path , query , fragment ) {
190- if ( flags & binding . URL_FLAGS_FAILED )
191- return ;
192188 this [ context ] . port = port ;
193189}
194190
195191function onParsePathComplete ( flags , protocol , username , password ,
196192 host , port , path , query , fragment ) {
197- if ( flags & binding . URL_FLAGS_FAILED )
198- return ;
199193 const ctx = this [ context ] ;
200194 if ( path ) {
201195 ctx . path = path ;
@@ -207,16 +201,12 @@ function onParsePathComplete(flags, protocol, username, password,
207201
208202function onParseSearchComplete ( flags , protocol , username , password ,
209203 host , port , path , query , fragment ) {
210- if ( flags & binding . URL_FLAGS_FAILED )
211- return ;
212204 const ctx = this [ context ] ;
213205 ctx . query = query ;
214206}
215207
216208function onParseHashComplete ( flags , protocol , username , password ,
217209 host , port , path , query , fragment ) {
218- if ( flags & binding . URL_FLAGS_FAILED )
219- return ;
220210 const ctx = this [ context ] ;
221211 if ( fragment ) {
222212 ctx . fragment = fragment ;
0 commit comments