Skip to content

Commit

Permalink
Lotame Panorama Id System: bug fixes (prebid#9092)
Browse files Browse the repository at this point in the history
* GRUE-246 fixed bug to test for emnpty value before returning, fixed bug to check for null values and to convert a string to an int before treating it as a timestamp.

* GRUE-246 Removed trailing space.
  • Loading branch information
Tonsil authored and jorgeluisrocha committed May 18, 2023
1 parent cc2793f commit fa257a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
16 changes: 10 additions & 6 deletions modules/lotamePanoramaIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const DAYS_TO_CACHE = 7;
const DAY_MS = 60 * 60 * 24 * 1000;
const MISSING_CORE_CONSENT = 111;
const GVLID = 95;
const ID_HOST = 'id.crwdcntrl.net';

export const storage = getStorageManager({gvlid: GVLID, moduleName: MODULE_NAME});
let cookieDomain;
Expand Down Expand Up @@ -57,12 +58,14 @@ function setProfileId(profileId) {
* Get the Lotame profile id by checking cookies first and then local storage
*/
function getProfileId() {
let profileId;
if (storage.cookiesAreEnabled()) {
return storage.getCookie(KEY_PROFILE, undefined);
profileId = storage.getCookie(KEY_PROFILE, undefined);
}
if (storage.hasLocalStorage()) {
return storage.getDataFromLocalStorage(KEY_PROFILE, undefined);
if (!profileId && storage.hasLocalStorage()) {
profileId = storage.getDataFromLocalStorage(KEY_PROFILE, undefined);
}
return profileId;
}

/**
Expand All @@ -78,10 +81,11 @@ function getFromStorage(key) {
const storedValueExp = storage.getDataFromLocalStorage(
`${key}_exp`, undefined
);
if (storedValueExp === '') {

if (storedValueExp === '' || storedValueExp === null) {
value = storage.getDataFromLocalStorage(key, undefined);
} else if (storedValueExp) {
if ((new Date(storedValueExp)).getTime() - Date.now() > 0) {
if ((new Date(parseInt(storedValueExp, 10))).getTime() - Date.now() > 0) {
value = storage.getDataFromLocalStorage(key, undefined);
}
}
Expand Down Expand Up @@ -284,7 +288,7 @@ export const lotamePanoramaIdSubmodule = {

const url = buildUrl({
protocol: 'https',
host: `id.crwdcntrl.net`,
host: ID_HOST,
pathname: '/id',
search: isEmpty(queryParams) ? undefined : queryParams,
});
Expand Down
1 change: 0 additions & 1 deletion test/spec/modules/lotamePanoramaIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ describe('LotameId', function() {

it('should call the remote server when getId is called', function () {
expect(request.url).to.be.eq('https://id.crwdcntrl.net/id');

expect(callBackSpy.calledOnce).to.be.true;
});

Expand Down

0 comments on commit fa257a9

Please sign in to comment.