-
Notifications
You must be signed in to change notification settings - Fork 563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(fetch#Request): Implements determineRequestReferrer
#1236
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please paste in the spec test similar to our other implementations.
Sure thing, I actually have two doubts in here:
AFAIU means the agent has full control about the
I'll cover your suggestions, add documentation (on code and for implementation) 👍 |
Codecov ReportBase: 94.89% // Head: 94.72% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1236 +/- ##
==========================================
- Coverage 94.89% 94.72% -0.18%
==========================================
Files 53 53
Lines 4803 4850 +47
==========================================
+ Hits 4558 4594 +36
- Misses 245 256 +11
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
626cd04
to
0b653eb
Compare
I'm not sure about those errors, any hint? 🤔 |
This seems pretty clear. |
ab81505
to
3c00c7f
Compare
Thanks for the hint @mcollina, but it seems it was a bad check on the Request environment, as I didn't check for possible undefined from the root object. Now shall be fixed, looking forward for feedback 🙂 |
lib/fetch/util.js
Outdated
const policy = request.referrerPolicy | ||
|
||
// Return no-referrer when empty or policy says so | ||
if (policy === '' || policy === 'no-referrer') return 'no-referrer' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (policy === '' || policy === 'no-referrer') return 'no-referrer' | |
if (policy === '' || policy === 'no-referrer') { | |
return 'no-referrer' | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not part of spec?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not explicitly, but if there's no value or the policy
explicitly says that there's no-referrer
, there's no point in continuing executing the spec algorithm. Any suggestion on how to handle it? 🙂
3aca452
to
073ac85
Compare
e04616c
to
9fdeccc
Compare
Hi @ronag, changes applied and conflicts fixed, let me know if there's anything else to change 👍 |
9fdeccc
to
215dc9a
Compare
@metcoder95 CI is still failing. |
lib/fetch/util.js
Outdated
*/ | ||
if (request.referrer === 'client') { | ||
// Not defined in Node but part of the spec | ||
if (environment?.globalObject instanceof Window) { // eslint-disable-line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be changed to something similar to
Line 414 in e5e5b97
request.client?.globalObject?.constructor?.name === 'Window' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, applied in 6ed09c1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't seem to have been done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, sorry for that. Change was made but didn't stage it for the commit 😓
Here it is the new one: 681a755
It seems the testing was failing due to some bad import. Fixed 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to add tests that use fetch
directly, instead of just testing the utility methods?
lib/fetch/util.js
Outdated
let originAsURL | ||
|
||
// If not valid because not semantically correct, return false | ||
try { originAsURL = new URL(origin) } catch (e) { return false } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be able to throw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, a bad bad origin
cannot happen without being priorly identified. Removed in 2ca0941
Sure, by just changing to a different value from |
@KhafraDev are we good here? |
* feat: poc of determineRequestReferrer * refactor: apply shortcut * feat(partial): apply switch referrer statement * refactor: add in-code documentation * feat: add check for window * docs: add comments * feat: add check for trustworthy/non-trustworthy urls * docs: add documentation about pottentially trustworthy * feat: expose pottentially trustworthy * test: URL potentially trustworthy * fix: check for possibly undefined * test: initial round * feat: smaller improvements * docs: update in-code docs * lint: ignore line * tests: add more test scenarios * refactor: small improvements * refactor: apply review * tests: adjust testing * refactor: apply PR review * refactor: smaller adjustements
* feat: poc of determineRequestReferrer * refactor: apply shortcut * feat(partial): apply switch referrer statement * refactor: add in-code documentation * feat: add check for window * docs: add comments * feat: add check for trustworthy/non-trustworthy urls * docs: add documentation about pottentially trustworthy * feat: expose pottentially trustworthy * test: URL potentially trustworthy * fix: check for possibly undefined * test: initial round * feat: smaller improvements * docs: update in-code docs * lint: ignore line * tests: add more test scenarios * refactor: small improvements * refactor: apply review * tests: adjust testing * refactor: apply PR review * refactor: smaller adjustements
Relates to #958
Pendings: