@@ -1300,7 +1300,7 @@ test('match domain and path using regexp', t => {
13001300// https://github.com/nock/nock/issues/1003
13011301test ( 'correctly parse request without specified path' , t => {
13021302 const scope1 = nock ( 'https://example.test' )
1303- . get ( '' )
1303+ . get ( '/ ' )
13041304 . reply ( 200 )
13051305
13061306 https
@@ -1317,7 +1317,7 @@ test('correctly parse request without specified path', t => {
13171317
13181318test ( 'data is sent with flushHeaders' , t => {
13191319 const scope1 = nock ( 'https://example.test' )
1320- . get ( '' )
1320+ . get ( '/ ' )
13211321 . reply ( 200 , 'this is data' )
13221322
13231323 https
@@ -1334,6 +1334,28 @@ test('data is sent with flushHeaders', t => {
13341334 . flushHeaders ( )
13351335} )
13361336
1337+ // https://github.com/nock/nock/issues/1730
1338+ test ( 'URL path without leading slash throws expected error' , t => {
1339+ t . throws ( ( ) => nock ( 'http://example.test' ) . get ( '' ) , {
1340+ message :
1341+ "Non-wildcard URL path strings must begin with a slash (otherwise they won't match anything) (got: )" ,
1342+ } )
1343+
1344+ t . end ( )
1345+ } )
1346+
1347+ test ( 'wildcard param URL should not throw error' , t => {
1348+ nock ( 'http://example.test' ) . get ( '*' )
1349+
1350+ t . end ( )
1351+ } )
1352+
1353+ test ( 'with filteringScope, URL path without leading slash does not throw error' , t => {
1354+ nock ( 'http://example.test' , { filteringScope : ( ) => { } } ) . get ( '' )
1355+
1356+ t . end ( )
1357+ } )
1358+
13371359test ( 'no new keys were added to the global namespace' , t => {
13381360 const leaks = Object . keys ( global ) . filter (
13391361 key => ! acceptableGlobalKeys . has ( key )
0 commit comments