Skip to content

Conversation

@jhadev
Copy link
Collaborator

@jhadev jhadev commented May 27, 2022

Example output

CleanShot 2022-05-26 at 20 27 51@2x

@jhadev jhadev requested a review from nucliweb May 27, 2022 05:51
@nucliweb
Copy link
Owner

nucliweb commented May 27, 2022

We need to improve the host validation.

A lot of sites use a subdomain for the resources (as a custom CDN), and these resources doesn't Thrid-party.

e.g. On this site, all the resources use a subdomain, and the script detects all the First Party Scripts as Third Party Scripts.

image

An options is add an array with the "first" hosts, and check the current host with this config hosts

const HOSTS = [ 'assets.domain.com', 'cdn.domain.com' ]
@jhadev
Copy link
Collaborator Author

jhadev commented May 27, 2022

You are right. Technically they aren't third party despite the fact they usually incur network cost. So the wording is kinda deceiving in this case. But you are totally right and like your idea

So basically create a hosts array for the user edit themselves and then add that to the first party check.

@jhadev
Copy link
Collaborator Author

jhadev commented May 27, 2022

Example using katespade.com just bc I knew a subdomain.
CleanShot 2022-05-27 at 13 57 21@2x

Please test on the site you used above. Thanks!

if (resource.initiatorType === "script") {
const { host } = new URL(resource.name);
// check if resource url host matches location.host = first party script
if (host === location.host || HOSTS.includes(host)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

Comment on lines +194 to +197
// set for first party scripts
const first = [];
// set for third party scripts
const third = [];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@nucliweb nucliweb merged commit 40f4202 into main May 27, 2022
@nucliweb nucliweb deleted the first-third-party-scripts branch May 27, 2022 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants