@@ -3142,46 +3142,25 @@ Then `request.url` will be:
3142
3142
' /status?name=ryan'
3143
3143
```
3144
3144
3145
- To parse the url into its parts, [ ` url.parse(request.url) ` ] [ `url.parse()` ] .
3145
+ To parse the url into its parts, ` new URL() ` can be used:
3146
3146
3147
3147
``` console
3148
3148
$ node
3149
- > url.parse(' /status?name=ryan' )
3150
- Url {
3151
- protocol: null,
3152
- slashes: null,
3153
- auth: null,
3154
- host: null,
3155
- port: null,
3156
- hostname: null,
3157
- hash: null,
3158
- search: '?name=ryan',
3159
- query: 'name=ryan',
3149
+ > new URL(' /status?name=ryan' , ' http://example.com' )
3150
+ URL {
3151
+ href: 'http://example.com/status?name=ryan',
3152
+ origin: 'http://example.com',
3153
+ protocol: 'http:',
3154
+ username: '',
3155
+ password: '',
3156
+ host: 'example.com',
3157
+ hostname: 'example.com',
3158
+ port: '',
3160
3159
pathname: '/status',
3161
- path: '/status?name=ryan',
3162
- href: '/status?name=ryan' }
3163
- ```
3164
-
3165
- To obtain the parameters from the query string, use the
3166
- [ ` querystring.parse() ` ] [ ] function or pass
3167
- ` true ` as the second argument to [ ` url.parse() ` ] [ ] .
3168
-
3169
- ``` console
3170
- $ node
3171
- > url.parse(' /status?name=ryan' , true)
3172
- Url {
3173
- protocol: null,
3174
- slashes: null,
3175
- auth: null,
3176
- host: null,
3177
- port: null,
3178
- hostname: null,
3179
- hash: null,
3180
3160
search: '?name=ryan',
3181
- query: { name: 'ryan' },
3182
- pathname: '/status',
3183
- path: '/status?name=ryan',
3184
- href: '/status?name=ryan' }
3161
+ searchParams: URLSearchParams { 'name' => 'ryan' },
3162
+ hash: ''
3163
+ }
3185
3164
```
3186
3165
3187
3166
### Class: ` http2.Http2ServerResponse `
@@ -3766,7 +3745,6 @@ you need to implement any fall-back behaviour yourself.
3766
3745
[ `net.Socket.prototype.unref()` ] : net.html#net_socket_unref
3767
3746
[ `net.Socket` ] : net.html#net_class_net_socket
3768
3747
[ `net.connect()` ] : net.html#net_net_connect
3769
- [ `querystring.parse()` ] : querystring.html#querystring_querystring_parse_str_sep_eq_options
3770
3748
[ `request.authority` ] : #http2_request_authority
3771
3749
[ `request.socket` ] : #http2_request_socket
3772
3750
[ `request.socket.getPeerCertificate()` ] : tls.html#tls_tlssocket_getpeercertificate_detailed
@@ -3782,7 +3760,6 @@ you need to implement any fall-back behaviour yourself.
3782
3760
[ `tls.TLSSocket` ] : tls.html#tls_class_tls_tlssocket
3783
3761
[ `tls.connect()` ] : tls.html#tls_tls_connect_options_callback
3784
3762
[ `tls.createServer()` ] : tls.html#tls_tls_createserver_options_secureconnectionlistener
3785
- [ `url.parse()` ] : url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
3786
3763
[ `writable.writableFinished` ] : stream.html#stream_writable_writablefinished
3787
3764
[ error code ] : #error_codes
3788
3765
[ Sensitive headers ] : #http2-sensitive-headers
0 commit comments