diff --git a/dist/load-cookie.html b/dist/load-cookie.html
index 70b228d3..a017d598 100644
--- a/dist/load-cookie.html
+++ b/dist/load-cookie.html
@@ -7,7 +7,7 @@
Document
diff --git a/src/cookieSync.js b/src/cookieSync.js
index ff2b1d38..a87d0cd4 100644
--- a/src/cookieSync.js
+++ b/src/cookieSync.js
@@ -1,8 +1,12 @@
const ENDPOINT = 'https://prebid.adnxs.com/pbs/v1/cookie_sync';
+/**
+ * checks to make sure URL is valid. Regex from https://validatejs.org/#validators-url, https://gist.github.com/dperini/729294
+ */
+const isValidUrl = new RegExp(/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i);
function doBidderSync(type, url, bidder) {
- if (!url) {
- console.log(`No sync url for bidder "${bidder}": ${url}`);
+ if (!url || !isValidUrl.test(url)) {
+ console.log(`No valid sync url for bidder "${bidder}": ${url}`);
} else if (type === 'image' || type === 'redirect') {
console.log(`Invoking image pixel user sync for bidder: "${bidder}"`);
triggerPixel(url);
diff --git a/testpages/hello_world_cookie_sync.html b/testpages/hello_world_cookie_sync.html
new file mode 100644
index 00000000..6fcfa333
--- /dev/null
+++ b/testpages/hello_world_cookie_sync.html
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file