Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
Cleaned the code a bit, removed console logs and comments. Also removed the "hh:mm:ss" format check in getSkipOffsetValue function in vast-maker.js.
  • Loading branch information
JinHedman committed Jun 19, 2024
1 parent b5ee9c7 commit fc7cb85
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
6 changes: 1 addition & 5 deletions utils/vast-maker.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const DEFAULT_AD_LIST = [
*
*/
function VastBuilder(params) {
console.log("VastBuilder params: ", params);
let vastObject = {};
let adList = [];
let vast = null;
Expand Down Expand Up @@ -352,16 +351,13 @@ function indexOfSmallest(a) {
return lowest;
}

// Validate that params.skipoffset is a valid VAST skipoffset value ("x%" or "hh:mm:ss").
function getSkipOffsetValue(skipoffset) {
// "hh:mm:ss"
const timeFormatRegex = /^(\d{2}):([0-5][0-9]):([0-5][0-9])$/;
// "x%"
const percentageFormatRegex = /^(100|[1-9]?[0-9])%$/;
// "seconds"
const integerSecondsRegex = /^\d+$/;

if (timeFormatRegex.test(skipoffset) || percentageFormatRegex.test(skipoffset)){
if (percentageFormatRegex.test(skipoffset)){
return skipoffset;
}
// convert seconds to "hh:mm:ss" format
Expand Down
1 change: 0 additions & 1 deletion utils/vmap-maker.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ function VmapBuilder(params) {

const breakpoints = params.breakpoints ? params.breakpoints.split(",").filter((item) => !isNaN(Number(item))) : [];
if (params.preroll) {
//console.log("PARAMS: ",params.generalVastConfigs);
const preVast = VastBuilder(defaultConfigs);
vmap.attachAdBreak("preroll.ad", "linear", "start", preVast.xml, {
sessionId: GVC.sessionId,
Expand Down

0 comments on commit fc7cb85

Please sign in to comment.