From 696f334d7e7cb53a9f5ee6e1b2dbfdc548c3d2e2 Mon Sep 17 00:00:00 2001 From: Carlos Fuentes Date: Tue, 8 Mar 2022 13:00:19 +0100 Subject: [PATCH] fix: check for possibly undefined --- lib/fetch/util.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/fetch/util.js b/lib/fetch/util.js index e64747cf7de..0e93fe468f9 100644 --- a/lib/fetch/util.js +++ b/lib/fetch/util.js @@ -299,7 +299,7 @@ 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' @@ -307,7 +307,7 @@ function determineRequestsReferrer (request) { } 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' } @@ -409,7 +409,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