File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -1439,7 +1439,7 @@ function hasAuthenticationEntry (request) {
14391439 */
14401440function includesCredentials ( url ) {
14411441 // A URL includes credentials if its username or password is not the empty string.
1442- return ! ! ( url . username && url . password )
1442+ return ! ! ( url . username || url . password )
14431443}
14441444
14451445/**
Original file line number Diff line number Diff line change 1+ 'use strict'
2+
3+ const { test } = require ( 'node:test' )
4+ const { includesCredentials } = require ( '../../lib/web/fetch/util' )
5+
6+ test ( 'includesCredentials returns true for URL with both username and password' , ( ) => {
7+ const url = new URL ( 'http://user:pass@example.com' )
8+ require ( 'node:assert' ) . strictEqual ( includesCredentials ( url ) , true )
9+ } )
10+
11+ test ( 'includesCredentials returns true for URL with only username' , ( ) => {
12+ const url = new URL ( 'http://user@example.com' )
13+ require ( 'node:assert' ) . strictEqual ( includesCredentials ( url ) , true )
14+ } )
15+
16+ test ( 'includesCredentials returns true for URL with only password' , ( ) => {
17+ const url = new URL ( 'http://:pass@example.com' )
18+ require ( 'node:assert' ) . strictEqual ( includesCredentials ( url ) , true )
19+ } )
20+
21+ test ( 'includesCredentials returns false for URL with no credentials' , ( ) => {
22+ const url = new URL ( 'http://example.com' )
23+ require ( 'node:assert' ) . strictEqual ( includesCredentials ( url ) , false )
24+ } )
You can’t perform that action at this time.
0 commit comments