Skip to content

Commit

Permalink
Merge pull request #12 from Lotame/feature/GRUE-177_more_prebid_tests
Browse files Browse the repository at this point in the history
Feature/grue 177 more prebid tests
  • Loading branch information
Tonsil authored Aug 29, 2022
2 parents f7e4397 + 06f2d36 commit f0585df
Show file tree
Hide file tree
Showing 2 changed files with 11 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
2 changes: 1 addition & 1 deletion test/spec/modules/lotamePanoramaIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ 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 f0585df

Please sign in to comment.