-
Notifications
You must be signed in to change notification settings - Fork 0
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
Taboola Adapter - Adding Optional Chaining #11
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,13 +60,13 @@ export const userData = { | |
|
||
export const internal = { | ||
getPageUrl: (refererInfo = {}) => { | ||
return refererInfo.page || getWindowSelf().location.href; | ||
return refererInfo?.page || getWindowSelf().location?.href; | ||
}, | ||
getReferrer: (refererInfo = {}) => { | ||
if (refererInfo.ref) { | ||
if (refererInfo?.ref) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ahmadlob here we don't need the ?, because we check if (refererInfo.ref) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the condition here checks if "refererInfo.ref" is null. the chaining I added -> If "refererInfo" is null - evaluate "undefined" and the general condition to be falsy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed it to be much more shorter |
||
return refererInfo.ref; | ||
} else { | ||
return getWindowSelf().document.referrer; | ||
return getWindowSelf().document?.referrer; | ||
} | ||
} | ||
} | ||
|
@@ -160,7 +160,7 @@ function getSiteProperties({publisherId, bcat = []}, refererInfo) { | |
return { | ||
id: publisherId, | ||
name: publisherId, | ||
domain: refererInfo?.domain || window.location.host, | ||
domain: refererInfo?.domain || window.location?.host, | ||
page: getPageUrl(refererInfo), | ||
ref: getReferrer(refererInfo), | ||
publisher: { | ||
|
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.
@ahmadlob getWindowSelf().location can be null?
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.
removed the check