From 04a7c760e6d0659dbbcb984c97bd42b954a55786 Mon Sep 17 00:00:00 2001 From: songtungmtp Date: Wed, 20 Nov 2019 16:08:14 +0900 Subject: [PATCH] review comments fix, remove deprecated functions, fix unit test --- modules/smmsBidAdapter.js | 21 ++++++++------------- test/spec/modules/smmsBidAdapter_spec.js | 4 ++-- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/modules/smmsBidAdapter.js b/modules/smmsBidAdapter.js index 3e65cfd3c39..dafd4aba734 100644 --- a/modules/smmsBidAdapter.js +++ b/modules/smmsBidAdapter.js @@ -2,9 +2,9 @@ import * as utils from '../src/utils'; import { registerBidder } from '../src/adapters/bidderFactory'; const BIDDER_CODE = 'smms'; -const ENDPOINT_BANNER = '//bidder.mediams.mb.softbank.jp/api/v1/prebid/banner'; -const ENDPOINT_NATIVE = '//bidder.mediams.mb.softbank.jp/api/v1/prebid/native'; -const COOKIE_SYNC_URL = '//bidder.mediams.mb.softbank.jp/api/v1/cookie/gen'; +const ENDPOINT_BANNER = 'https://bidder.mediams.mb.softbank.jp/api/v1/prebid/banner'; +const ENDPOINT_NATIVE = 'https://bidder.mediams.mb.softbank.jp/api/v1/prebid/native'; +const COOKIE_SYNC_URL = 'https://bidder.mediams.mb.softbank.jp/api/v1/cookie/gen'; const SUPPORTED_MEDIA_TYPES = ['banner', 'native']; const SUPPORTED_CURRENCIES = ['USD', 'JPY']; const DEFAULT_CURRENCY = 'JPY'; @@ -29,13 +29,12 @@ export function _getUrlVars(url) { export const spec = { code: BIDDER_CODE, - aliases: ['smms'], // short code supportedMediaTypes: SUPPORTED_MEDIA_TYPES, isBidRequestValid: function(bid) { let valid = !!(bid.params.placementId); if (valid && bid.params.hasOwnProperty('currency')) { if (SUPPORTED_CURRENCIES.indexOf(bid.params.currency) === -1) { - console.log('Invalid currency type, we support only JPY and USD!'); + utils.logError('Invalid currency type, we support only JPY and USD!'); valid = false; } } @@ -54,6 +53,7 @@ export const spec = { if (bidderRequest && bidderRequest.refererInfo) { refererInfo = bidderRequest.refererInfo; } + const g = (typeof (geparams) !== 'undefined' && typeof (geparams) == 'object' && geparams) ? geparams : {}; validBidRequests.forEach((bid, i) => { let endpoint = ENDPOINT_BANNER; @@ -62,14 +62,15 @@ export const spec = { 'cur': bid.params.hasOwnProperty('currency') ? bid.params.currency : DEFAULT_CURRENCY, 'ua': navigator.userAgent, 'adtk': _encodeURIComponent(g.lat ? '0' : '1'), - 'loc': utils.getTopWindowUrl(), + 'loc': (refererInfo && refererInfo.referer) ? refererInfo.referer : '', 'topframe': (window.parent == window.self) ? 1 : 0, 'sw': screen && screen.width, 'sh': screen && screen.height, 'cb': Math.floor(Math.random() * 99999999999), 'tpaf': 1, 'cks': 1, - 'requestid': bid.bidId + 'requestid': bid.bidId, + 'referer': (refererInfo && refererInfo.referer) ? refererInfo.referer : '' }; if (bid.hasOwnProperty('nativeParams')) { @@ -79,12 +80,6 @@ export const spec = { data.apiv = '1.1.0'; } - if (refererInfo && refererInfo.referer) { - data.referer = refererInfo.referer; - } else { - data.referer = ''; - } - serverRequests.push({ method: 'GET', url: endpoint, diff --git a/test/spec/modules/smmsBidAdapter_spec.js b/test/spec/modules/smmsBidAdapter_spec.js index fff2a224641..3ed952811ea 100644 --- a/test/spec/modules/smmsBidAdapter_spec.js +++ b/test/spec/modules/smmsBidAdapter_spec.js @@ -2,8 +2,8 @@ import {expect} from 'chai'; import {spec, _getUrlVars} from 'modules/smmsBidAdapter'; import * as utils from 'src/utils'; -const BASE_URI = '//bidder.mediams.mb.softbank.jp/api/v1/prebid/banner' -const NATIVE_BASE_URI = '//bidder.mediams.mb.softbank.jp/api/v1/prebid/native' +const BASE_URI = 'https://bidder.mediams.mb.softbank.jp/api/v1/prebid/banner' +const NATIVE_BASE_URI = 'https://bidder.mediams.mb.softbank.jp/api/v1/prebid/native' describe('smms adapter', function() { let bidRequests;