Skip to content

Commit

Permalink
removing deprecated url library
Browse files Browse the repository at this point in the history
  • Loading branch information
BatMiles committed Aug 28, 2024
1 parent d2ade34 commit e5e130f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/canvas-fingerprinting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { BlacklightEvent, JsInstrumentEvent } from './types';
* Implemented following the Princeton study's methodology.
*/

import { parse } from 'url';
import { getScriptUrl, serializeCanvasCallMap } from './utils';

const MIN_CANVAS_IMAGE_WIDTH = 16;
Expand Down Expand Up @@ -68,7 +67,7 @@ export const sortCanvasCalls = (canvasCalls: BlacklightEvent[]) => {
const cStyles = new Map() as CanvasCallMap;
for (const item of canvasCalls) {
const { url, data } = item as JsInstrumentEvent;
const url_host = parse(url).hostname;
const url_host = new URL(url).hostname;
const script_url = getScriptUrl(item);
const { symbol, operation, value } = data;
if (typeof script_url === 'undefined' || script_url.indexOf('http:') < -1 || script_url.indexOf('https:') < -1) {
Expand Down
5 changes: 3 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const getScriptUrl = (item: BlacklightEvent) => {
const { stack } = item;

for (let i = 0; i < stack.length; i++) {
if (stack[i].hasOwnProperty('fileName')) {
if (Object.prototype.hasOwnProperty.call(stack[i], 'fileName')) {
return stack[i].fileName;
} else {
if (i === stack.length - 1) {
Expand All @@ -95,12 +95,13 @@ export const loadEventData = (dir, filename = 'inspection-log.ndjson') => {
.map(m => loadJSONSafely(m))
.filter(m => m.level === 'warn');
};

// Not using this atm but leaving it in because it might be useful in the future
export const getStackType = (stack, firstPartyDomain) => {
let hasFirstParty = false;
let hasThirdParty = false;
stack.forEach(s => {
if (s.hasOwnProperty('fileName')) {
if (Object.prototype.hasOwnProperty.call(s, 'fileName')) {
const scriptDomain = getDomain(s.fileName);
if (scriptDomain === firstPartyDomain) {
hasFirstParty = true;
Expand Down

0 comments on commit e5e130f

Please sign in to comment.