@@ -353,7 +353,7 @@ describe('modifyRequest.onBeforeRequest:', function () {
353
353
describe ( 'request for IPFS path at the localhost' , function ( ) {
354
354
// we do not touch local requests, as it may interfere with other nodes running at the same machine
355
355
// or could produce false-positives such as redirection from localhost:5001/ipfs/path to localhost:8080/ipfs/path
356
- it ( 'should fix localhost API hostname to IP' , function ( ) {
356
+ it ( 'should fix localhost Kubo RPC hostname to IP' , function ( ) {
357
357
const request = url2request ( 'http://localhost:5001/ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DoZRQ/' )
358
358
// expectNoRedirect(modifyRequest, request)
359
359
expect ( modifyRequest . onBeforeRequest ( request ) . redirectUrl )
@@ -375,14 +375,14 @@ describe('modifyRequest.onBeforeRequest:', function () {
375
375
expect ( modifyRequest . onBeforeRequest ( request ) . redirectUrl )
376
376
. to . equal ( 'http://127.0.0.1:5001/ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DoZRQ/' )
377
377
} )
378
- it ( 'should fix localhost API to IP ' , function ( ) {
378
+ it ( 'should be left untouched if /webui on localhost Kubo RPC port ' , function ( ) {
379
379
// https://github.com/ipfs/ipfs-companion/issues/291
380
380
const request = url2request ( 'http://localhost:5001/webui' )
381
381
// expectNoRedirect(modifyRequest, request)
382
382
expect ( modifyRequest . onBeforeRequest ( request ) . redirectUrl )
383
383
. to . equal ( 'http://127.0.0.1:5001/webui' )
384
384
} )
385
- it ( 'should be left untouched if localhost API IP is used, even when x-ipfs-path is present' , function ( ) {
385
+ it ( 'should be left untouched if localhost Kubo RPC IP is used, even when x-ipfs-path is present' , function ( ) {
386
386
// https://github.com/ipfs-shipyard/ipfs-companion/issues/604
387
387
const request = url2request ( 'http://127.0.0.1:5001/ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DoZRQ/' )
388
388
request . responseHeaders = [ { name : 'X-Ipfs-Path' , value : '/ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DDIFF' } ]
@@ -431,21 +431,28 @@ describe('modifyRequest.onBeforeRequest:', function () {
431
431
global . browser = browser
432
432
state . ipfsNodeType = 'external'
433
433
state . redirect = true
434
- state . peerCount = - 1
434
+ state . peerCount = - 1 // this simulates Kubo RPC being offline
435
435
state . gwURLString = 'http://localhost:8080'
436
436
state . gwURL = new URL ( 'http://localhost:8080' )
437
437
state . pubGwURLString = 'https://ipfs.io'
438
438
state . pubGwURL = new URL ( 'https://ipfs.io' )
439
- state . redirect = false
440
439
} )
441
440
it ( 'should present recovery page if node is offline' , function ( ) {
442
441
expect ( state . nodeActive ) . to . be . equal ( false )
443
442
const request = url2request ( 'https://localhost:8080/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR/foo/bar' )
444
443
expect ( modifyRequest . onBeforeRequest ( request ) . redirectUrl ) . to . equal ( 'chrome-extension://testid/dist/recovery/recovery.html#https%3A%2F%2Fipfs.io%2Fipfs%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%2Ffoo%2Fbar' )
445
444
} )
446
- it ( 'should not block requests when the request is redirecting' , function ( ) {
445
+ it ( 'should not show recovery page if node is offline, redirect is enabled, but non-gateway URL failed to load from the same port' , function ( ) {
446
+ // this covers https://github.com/ipfs/ipfs-companion/issues/1162 and https://twitter.com/unicomp21/status/1626244123102679041
447
447
state . redirect = true
448
448
expect ( state . nodeActive ) . to . be . equal ( false )
449
+ const request = url2request ( 'https://localhost:8080/' )
450
+ expect ( modifyRequest . onBeforeRequest ( request ) ) . to . equal ( undefined )
451
+ } )
452
+ it ( 'should not show recovery page if extension is disabled' , function ( ) {
453
+ // allows user to quickly avoid anything similar to https://github.com/ipfs/ipfs-companion/issues/1162
454
+ state . active = false
455
+ expect ( state . nodeActive ) . to . be . equal ( false )
449
456
const request = url2request ( 'https://localhost:8080/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR/foo/bar' )
450
457
expect ( modifyRequest . onBeforeRequest ( request ) ) . to . equal ( undefined )
451
458
} )
0 commit comments