Skip to content

Commit

Permalink
docs: update in-code docs
Browse files Browse the repository at this point in the history
  • Loading branch information
metcoder95 committed Mar 23, 2022
1 parent 073ac85 commit 6b084c2
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lib/fetch/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ function clonePolicyContainer () {

// https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer
function determineRequestsReferrer (request) {
// TODO
// 1. Let policy be request's referrer policy.
const policy = request.referrerPolicy

Expand All @@ -297,14 +296,29 @@ function determineRequestsReferrer (request) {
const environment = request.client
let referrerSource = null

// TODO
// 3(a) If policy is "origin", then
// 3(a)(I) If environment's global object is Window then
/**
* 3, Switch on request’s referrer:
"client"
If environment’s global object is a Window object, then
Let document be the associated Document of environment’s global object.
If document’s origin is an opaque origin, return no referrer.
While document is an iframe srcdoc document,
let document be document’s browsing context’s browsing context container’s node document.
Let referrerSource be document’s URL.
Otherwise, let referrerSource be environment’s creation URL.
a URL
Let referrerSource be request’s referrer.
*/
if (request.referrer === 'client') {
if (environment?.globalObject instanceof Window) {
const origin = environment.globalObject.self?.origin ?? environment.globalObject.location?.origin

// If document’s origin is an opaque origin, return no referrer.
if (origin == null || origin === 'null') return 'no-referrer'

// Let referrerSource be document’s URL.
referrerSource = new URL(environment.globalObject.location.href)
} else {
// 3(a)(II) If environment's global object is not Window,
Expand Down

0 comments on commit 6b084c2

Please sign in to comment.