Skip to content

Commit

Permalink
fix: check for possibly undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
metcoder95 committed Mar 8, 2022
1 parent 3c00c7f commit f6a63d4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/fetch/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,15 @@ function determineRequestsReferrer (request) {
// 3(a) If policy is "origin", then
// 3(a)(I) If environment's global object is Window then
if (request.referrer === 'client') {
if (environment.globalObject instanceof Window) {
if (environment?.globalObject instanceof Window) {
const origin = environment.globalObject.self?.origin ?? environment.globalObject.location?.origin

if (origin == null || origin === 'null') return 'no-referrer'
referrerSource = new URL(environment.globalObject.location.href)
} else {
// 3(a)(II) If environment's global object is not Window,
// Let referrerSource be environments creationURL
if (environment.globalObject.location == null) {
if (environment?.globalObject?.location == null) {
return 'no-referrer'
}

Expand Down Expand Up @@ -410,7 +410,7 @@ function isURLPotentiallyTrustworthy (url) {

// If scheme is data, return true
if (url.protocol === 'data:') return true

// If file, return true
if (url.protocol === 'file:') return true

Expand Down

0 comments on commit f6a63d4

Please sign in to comment.