File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -444,6 +444,13 @@ function normalizeArguments(url, opts) {
444444 throw new TypeError ( `Parameter \`url\` must be a string or object, not ${ is ( url ) } ` ) ;
445445 } else if ( is . string ( url ) ) {
446446 url = url . replace ( / ^ u n i x : / , 'http://$&' ) ;
447+
448+ try {
449+ decodeURI ( url ) ;
450+ } catch ( err ) {
451+ throw new Error ( 'Parameter `url` must contain valid UTF-8 character sequences' ) ;
452+ }
453+
447454 url = urlParseLax ( url ) ;
448455 if ( url . auth ) {
449456 throw new Error ( 'Basic authentication must be done with the `auth` option' ) ;
Original file line number Diff line number Diff line change @@ -29,6 +29,11 @@ test('url is required', async t => {
2929 t . regex ( err . message , / P a r a m e t e r ` u r l ` m u s t b e a s t r i n g o r o b j e c t , n o t u n d e f i n e d / ) ;
3030} ) ;
3131
32+ test ( 'url should be utf-8 encoded' , async t => {
33+ const err = await t . throws ( got ( `${ s . url } /%D2%E0%EB%EB%E8%ED` ) ) ;
34+ t . regex ( err . message , / P a r a m e t e r ` u r l ` m u s t c o n t a i n v a l i d U T F - 8 c h a r a c t e r s e q u e n c e s / ) ;
35+ } ) ;
36+
3237test ( 'options are optional' , async t => {
3338 t . is ( ( await got ( `${ s . url } /test` ) ) . body , '/test' ) ;
3439} ) ;
You can’t perform that action at this time.
0 commit comments