Skip to content
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

Utils updates #5092

Merged
merged 7 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions modules/adkernelAdnAnalyticsAdapter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import adapter from '../src/AnalyticsAdapter.js';
import CONSTANTS from '../src/constants.json';
import adapterManager from '../src/adapterManager.js';
import {parse} from '../src/url.js';
import * as utils from '../src/utils.js';
import {ajax} from '../src/ajax.js';
import { getStorageManager } from '../src/storageManager.js';
Expand Down Expand Up @@ -211,7 +210,7 @@ export function getUmtSource(pageUrl, referrer) {
if (se) {
return asUtm(se, ORGANIC, ORGANIC);
}
let parsedUrl = parse(pageUrl);
let parsedUrl = utils.parseUrl(pageUrl);
let [refHost, refPath] = getReferrer(referrer);
if (refHost && refHost !== parsedUrl.hostname) {
return asUtm(refHost, REFERRAL, REFERRAL, '', refPath);
Expand All @@ -238,12 +237,12 @@ export function getUmtSource(pageUrl, referrer) {
}

function getReferrer(referrer) {
let ref = parse(referrer);
let ref = utils.parseUrl(referrer);
return [ref.hostname, ref.pathname];
}

function getUTM(pageUrl) {
let urlParameters = parse(pageUrl).search;
let urlParameters = utils.parseUrl(pageUrl).search;
if (!urlParameters['utm_campaign'] || !urlParameters['utm_source']) {
return;
}
Expand Down
3 changes: 1 addition & 2 deletions modules/adkernelAdnBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as utils from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {parse as parseUrl} from '../src/url.js';

const DEFAULT_ADKERNEL_DSP_DOMAIN = 'tag.adkernel.com';
const DEFAULT_MIMES = ['video/mp4', 'video/webm', 'application/x-shockwave-flash', 'application/javascript'];
Expand Down Expand Up @@ -71,7 +70,7 @@ function buildRequestParams(tags, auctionId, transactionId, gdprConsent, uspCons
}

function buildSite(refInfo) {
let loc = parseUrl(refInfo.referer);
let loc = utils.parseUrl(refInfo.referer);
let result = {
page: `${loc.protocol}://${loc.hostname}${loc.pathname}`,
secure: ~~(loc.protocol === 'https')
Expand Down
3 changes: 1 addition & 2 deletions modules/adkernelBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import find from 'core-js/library/fn/array/find.js';
import includes from 'core-js/library/fn/array/includes.js';
import {parse as parseUrl} from '../src/url.js';

/*
* In case you're AdKernel whitelable platform's client who needs branded adapter to
Expand Down Expand Up @@ -274,7 +273,7 @@ function getLanguage() {
* Creates site description object
*/
function createSite(refInfo) {
let url = parseUrl(refInfo.referer);
let url = utils.parseUrl(refInfo.referer);
let site = {
'domain': url.hostname,
'page': `${url.protocol}://${url.hostname}${url.pathname}`
Expand Down
3 changes: 1 addition & 2 deletions modules/advangelistsBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as utils from '../src/utils.js';
import { parse as parseUrl } from '../src/url.js';
import { config } from '../src/config.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { VIDEO, BANNER } from '../src/mediaTypes.js';
Expand Down Expand Up @@ -293,7 +292,7 @@ function createVideoRequestData(bid, bidderRequest) {

function getTopWindowLocation(bidderRequest) {
let url = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer;
return parseUrl(config.getConfig('pageUrl') || url, { decodeSearchAsString: true });
return utils.parseUrl(config.getConfig('pageUrl') || url, { decodeSearchAsString: true });
}

function createBannerRequestData(bid, bidderRequest) {
Expand Down
3 changes: 1 addition & 2 deletions modules/adxcgAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ajax } from '../src/ajax.js';
import adapter from '../src/AnalyticsAdapter.js';
import adapterManager from '../src/adapterManager.js';
import CONSTANTS from '../src/constants.json';
import * as url from '../src/url.js';
import * as utils from '../src/utils.js';

/**
Expand Down Expand Up @@ -113,7 +112,7 @@ function mapBidWon (bidResponse) {
}

function send (data) {
let adxcgAnalyticsRequestUrl = url.format({
let adxcgAnalyticsRequestUrl = utils.buildUrl({
protocol: 'https',
hostname: adxcgAnalyticsAdapter.context.host,
pathname: '/pbrx/v2',
Expand Down
3 changes: 1 addition & 2 deletions modules/adxcgBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { config } from '../src/config.js'
import * as utils from '../src/utils.js'
import * as url from '../src/url.js'
import { registerBidder } from '../src/adapters/bidderFactory.js'
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js'
import includes from 'core-js/library/fn/array/includes.js'
Expand Down Expand Up @@ -179,7 +178,7 @@ export const spec = {
beaconParams.idl_env = validBidRequests[0].userId.idl_env;
}

let adxcgRequestUrl = url.format({
let adxcgRequestUrl = utils.buildUrl({
protocol: 'https',
hostname: 'hbps.adxcg.net',
pathname: '/get/adi',
Expand Down
4 changes: 1 addition & 3 deletions modules/adyoulikeBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import * as utils from '../src/utils.js';
import { format } from '../src/url.js';
// import { config } from '../src/config.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import find from 'core-js/library/fn/array/find.js';

Expand Down Expand Up @@ -145,7 +143,7 @@ function getPageRefreshed() {
/* Create endpoint url */
function createEndpoint(bidRequests, bidderRequest) {
let host = getHostname(bidRequests);
return format({
return utils.buildUrl({
protocol: 'https',
host: `${DEFAULT_DC}${host}.omnitagjs.com`,
pathname: '/hb-api/prebid/v1',
Expand Down
3 changes: 1 addition & 2 deletions modules/audienceNetworkBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* @file AudienceNetwork adapter.
*/
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { formatQS } from '../src/url.js';
import { generateUUID, deepAccess, convertTypes } from '../src/utils.js';
import { generateUUID, deepAccess, convertTypes, formatQS } from '../src/utils.js';
import findIndex from 'core-js/library/fn/array/find-index.js';
import includes from 'core-js/library/fn/array/includes.js';

Expand Down
3 changes: 1 addition & 2 deletions modules/beachfrontBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as utils from '../src/utils.js';
import { parse as parseUrl } from '../src/url.js';
import { config } from '../src/config.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { Renderer } from '../src/Renderer.js';
Expand Down Expand Up @@ -247,7 +246,7 @@ function isBannerBidValid(bid) {

function getTopWindowLocation(bidderRequest) {
let url = bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer;
return parseUrl(config.getConfig('pageUrl') || url, { decodeSearchAsString: true });
return utils.parseUrl(config.getConfig('pageUrl') || url, { decodeSearchAsString: true });
}

function getTopWindowReferrer() {
Expand Down
3 changes: 1 addition & 2 deletions modules/brightcomBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as utils from '../src/utils.js';
import * as url from '../src/url.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER } from '../src/mediaTypes.js';
import { config } from '../src/config.js';
Expand Down Expand Up @@ -57,7 +56,7 @@ function buildRequests(bidReqs, bidderRequest) {
id: utils.getUniqueIdentifierStr(),
imp: brightcomImps,
site: {
domain: url.parse(referrer).host,
domain: utils.parseUrl(referrer).host,
page: referrer,
publisher: {
id: publisherId
Expand Down
3 changes: 1 addition & 2 deletions modules/criteoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { loadExternalScript } from '../src/adloader.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { parse } from '../src/url.js';
import * as utils from '../src/utils.js';
import find from 'core-js/library/fn/array/find.js';
import { verify } from 'criteo-direct-rsa-validate/build/verify.js';
Expand Down Expand Up @@ -200,7 +199,7 @@ function buildContext(bidRequests, bidderRequest) {
if (bidderRequest && bidderRequest.refererInfo) {
referrer = bidderRequest.refererInfo.referer;
}
const queryString = parse(referrer).search;
const queryString = utils.parseUrl(referrer).search;

const context = {
url: referrer,
Expand Down
3 changes: 1 addition & 2 deletions modules/criteoIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import * as utils from '../src/utils.js'
import * as ajax from '../src/ajax.js'
import * as urlLib from '../src/url.js'
import { getRefererInfo } from '../src/refererDetection.js'
import { submodule } from '../src/hook.js';
import { getStorageManager } from '../src/storageManager.js';
Expand All @@ -30,7 +29,7 @@ function areCookiesWriteable() {
}

function extractProtocolHost (url, returnOnlyHost = false) {
const parsedUrl = urlLib.parse(url)
const parsedUrl = utils.parseUrl(url)
return returnOnlyHost
? `${parsedUrl.hostname}`
: `${parsedUrl.protocol}://${parsedUrl.hostname}${parsedUrl.port ? ':' + parsedUrl.port : ''}/`;
Expand Down
3 changes: 1 addition & 2 deletions modules/datablocksBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as utils from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { parse as parseUrl } from '../src/url.js';
const NATIVE_MAP = {
'body': 2,
'body2': 10,
Expand Down Expand Up @@ -61,7 +60,7 @@ export const spec = {
let imps = {};
let site = {};
let device = {};
let refurl = parseUrl(bidderRequest.referrer);
let refurl = utils.parseUrl(bidderRequest.referrer);
let requests = [];

validBidRequests.forEach(bidRequest => {
Expand Down
5 changes: 2 additions & 3 deletions modules/dfpAdServerVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

import { registerVideoSupport } from '../src/adServerManager.js';
import { targeting } from '../src/targeting.js';
import { formatQS, format as buildUrl, parse } from '../src/url.js';
import { deepAccess, isEmpty, logError, parseSizesInput } from '../src/utils.js';
import { deepAccess, isEmpty, logError, parseSizesInput, formatQS, parseUrl, buildUrl } from '../src/utils.js';
import { config } from '../src/config.js';
import { getHook, submodule } from '../src/hook.js';
import { auctionManager } from '../src/auctionManager.js';
Expand Down Expand Up @@ -74,7 +73,7 @@ export function buildDfpVideoUrl(options) {
if (options.url) {
// when both `url` and `params` are given, parsed url will be overwriten
// with any matching param components
urlComponents = parse(options.url, {noDecodeWholeURL: true});
urlComponents = parseUrl(options.url, {noDecodeWholeURL: true});

if (isEmpty(options.params)) {
return buildUrlFromAdserverUrlComponents(urlComponents, bid, options);
Expand Down
16 changes: 8 additions & 8 deletions modules/emoteevBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import {
deepAccess,
isArray,
isInteger,
getParameterByName
getParameterByName,
buildUrl
} from '../src/utils.js';
import {config} from '../src/config.js';
import * as url from '../src/url.js';
import { getStorageManager } from '../src/storageManager.js';

export const storage = getStorageManager();
Expand Down Expand Up @@ -234,7 +234,7 @@ export const domain = (env) => {
* @param {string} env Emoteev environment parameter
* @returns {string} The full URL which events is sent to.
*/
export const eventsUrl = env => url.format({
export const eventsUrl = env => buildUrl({
protocol: (env === DEVELOPMENT) ? 'http' : 'https',
hostname: domain(env),
pathname: EVENTS_PATH
Expand All @@ -246,7 +246,7 @@ export const eventsUrl = env => url.format({
* @param {string} env Emoteev environment parameter
* @returns {string} The full URL which bidderRequest is sent to.
*/
export const bidderUrl = env => url.format({
export const bidderUrl = env => buildUrl({
protocol: (env === DEVELOPMENT) ? 'http' : 'https',
hostname: domain(env),
pathname: BIDDER_PATH
Expand All @@ -258,7 +258,7 @@ export const bidderUrl = env => url.format({
* @param {string} env Emoteev environment parameter
* @returns {string} The full URL called for iframe-based user sync
*/
export const userSyncIframeUrl = env => url.format({
export const userSyncIframeUrl = env => buildUrl({
protocol: (env === DEVELOPMENT) ? 'http' : 'https',
hostname: domain(env),
pathname: USER_SYNC_IFRAME_PATH
Expand All @@ -270,7 +270,7 @@ export const userSyncIframeUrl = env => url.format({
* @param {string} env Emoteev environment parameter
* @returns {string} The full URL called for image-based user sync
*/
export const userSyncImageUrl = env => url.format({
export const userSyncImageUrl = env => buildUrl({
protocol: (env === DEVELOPMENT) ? 'http' : 'https',
hostname: domain(env),
pathname: USER_SYNC_IMAGE_PATH
Expand Down Expand Up @@ -508,12 +508,12 @@ export const spec = {
bidderRequest),
interpretResponse: interpretResponse,
onBidWon: (bidObject) =>
triggerPixel(url.format(onBidWon(
triggerPixel(buildUrl(onBidWon(
resolveEnv(config.getConfig(), getParameterByName('emoteevEnv')),
storage.getCookie('_pubcid'),
bidObject))),
onTimeout: (bidRequest) =>
triggerPixel(url.format(onTimeout(
triggerPixel(buildUrl(onTimeout(
resolveEnv(config.getConfig(), getParameterByName('emoteevEnv')),
bidRequest))),
getUserSyncs: (syncOptions) =>
Expand Down
3 changes: 1 addition & 2 deletions modules/emx_digitalBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { Renderer } from '../src/Renderer.js';
import includes from 'core-js/library/fn/array/includes.js';
import {parse as parseUrl} from '../src/url.js';

const BIDDER_CODE = 'emx_digital';
const ENDPOINT = 'hb.emxdgt.com';
Expand Down Expand Up @@ -130,7 +129,7 @@ export const emxAdapter = {
}
},
getSite: (refInfo) => {
let url = parseUrl(refInfo.referer);
let url = utils.parseUrl(refInfo.referer);
return {
domain: url.hostname,
page: refInfo.referer,
Expand Down
3 changes: 1 addition & 2 deletions modules/fintezaAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ajax } from '../src/ajax.js';
import adapter from '../src/AnalyticsAdapter.js';
import adapterManager from '../src/adapterManager.js';
import * as utils from '../src/utils.js';
import { parse as parseURL } from '../src/url.js';
import { getStorageManager } from '../src/storageManager.js';

const storage = getStorageManager();
Expand All @@ -29,7 +28,7 @@ function getPageInfo() {
}

if (document.referrer) {
pageInfo.referrerDomain = parseURL(document.referrer).hostname;
pageInfo.referrerDomain = utils.parseUrl(document.referrer).hostname;
}

return pageInfo;
Expand Down
3 changes: 1 addition & 2 deletions modules/konduitWrapper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { registerVideoSupport } from '../src/adServerManager.js';
import { targeting } from '../src/targeting.js';
import { format as buildUrl } from '../src/url.js';
import * as utils from '../src/utils.js';
import { config } from '../src/config.js';

Expand Down Expand Up @@ -52,7 +51,7 @@ export function buildVastUrl(options) {
let resultingUrl = null;

if (queryParams.konduit_url) {
resultingUrl = buildUrl({
resultingUrl = utils.buildUrl({
protocol: 'https',
host: 'p.konduit.me',
pathname: '/api/vastProxy',
Expand Down
5 changes: 2 additions & 3 deletions modules/medianetAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import CONSTANTS from '../src/constants.json';
import * as utils from '../src/utils.js';
import { ajax } from '../src/ajax.js';
import { getRefererInfo } from '../src/refererDetection.js';
import * as url from '../src/url.js';
import { getPriceGranularity, AUCTION_IN_PROGRESS, AUCTION_COMPLETED } from '../src/auction.js'

const analyticsType = 'endpoint';
Expand Down Expand Up @@ -120,7 +119,7 @@ class Configure {

init() {
// Forces Logging % to 100%
let urlObj = url.parse(pageDetails.page);
let urlObj = utils.parseUrl(pageDetails.page);
if (utils.deepAccess(urlObj, 'search.medianet_test') || urlObj.hostname === 'localhost') {
this.loggingPercent = 100;
this.ajaxState = CONFIG_PASS;
Expand All @@ -144,7 +143,7 @@ class PageDetail {
const twitterUrl = this._getUrlFromSelector('meta[name="twitter:url"]', 'content');
const refererInfo = getRefererInfo();

this.domain = url.parse(refererInfo.referer).host;
this.domain = utils.parseUrl(refererInfo.referer).host;
this.page = refererInfo.referer;
this.is_top = refererInfo.reachedTop;
this.referrer = this._getTopWindowReferrer();
Expand Down
Loading