keen-tracking
Advanced tools
Comparing version 1.4.1 to 1.4.2
@@ -25,7 +25,7 @@ var pkg = require('../package.json'); | ||
uuid = helpers.getUniqueId(); | ||
var domainName = helpers.getDomainName(window.location.host); | ||
cookie.set('uuid', uuid, | ||
domainName && options.shareUuidAcrossDomains ? { | ||
domain: '.' + domainName | ||
} : {}); | ||
var domainName = helpers.getDomainName(window.location.hostname); | ||
var cookieDomain = domainName && options.shareUuidAcrossDomains ? { | ||
domain: '.' + domainName | ||
} : {}; | ||
cookie.set('uuid', uuid, cookieDomain); | ||
} | ||
@@ -32,0 +32,0 @@ |
@@ -1,6 +0,39 @@ | ||
function getDomainName(host){ | ||
var domainRegex = /\w+\.\w+$/; | ||
return domainRegex.test(host) ? host.match(domainRegex)[0] : null; | ||
function extractHostname(url) { | ||
var hostname; | ||
//find & remove protocol (http, ftp, etc.) and get hostname | ||
if (url.indexOf("://") > -1) { | ||
hostname = url.split('/')[2]; | ||
} | ||
else { | ||
hostname = url.split('/')[0]; | ||
} | ||
//find & remove port number | ||
hostname = hostname.split(':')[0]; | ||
//find & remove "?" | ||
hostname = hostname.split('?')[0]; | ||
return hostname; | ||
} | ||
// To address those who want the "root domain," use this function: | ||
function getDomainName(url) { | ||
var domain = extractHostname(url), | ||
splitArr = domain.split('.'), | ||
arrLen = splitArr.length; | ||
//extracting the root domain here | ||
//if there is a subdomain | ||
if (arrLen > 2) { | ||
domain = splitArr[arrLen - 2] + '.' + splitArr[arrLen - 1]; | ||
//check to see if it's using a Country Code Top Level Domain (ccTLD) (i.e. ".me.uk") | ||
if (splitArr[arrLen - 2].length == 2 && splitArr[arrLen - 1].length == 2) { | ||
//this is using a ccTLD | ||
domain = splitArr[arrLen - 3] + '.' + domain; | ||
} | ||
} | ||
return domain; | ||
} | ||
module.exports = getDomainName; |
@@ -36,5 +36,5 @@ var Cookies = require('js-cookie'); | ||
cookie.prototype.set = function(str, value){ | ||
cookie.prototype.set = function(str, value, options){ | ||
if (!arguments.length || !this.enabled()) return this; | ||
if (typeof str === 'string' && arguments.length === 2) { | ||
if (typeof str === 'string' && arguments.length >= 2) { | ||
this.data[str] = value ? value : null; | ||
@@ -45,3 +45,3 @@ } | ||
} | ||
Cookies.set(this.config.key, this.data, this.config.options); | ||
Cookies.set(this.config.key, this.data, extend(this.config.options, options || {})); | ||
return this; | ||
@@ -48,0 +48,0 @@ }; |
{ | ||
"name": "keen-tracking", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "Data Collection SDK for Keen IO", | ||
@@ -5,0 +5,0 @@ "main": "lib/server.js", |
@@ -14,3 +14,3 @@ # keen-tracking.js [![Build Status](https://travis-ci.org/keen/keen-tracking.js.svg?branch=master)](https://travis-ci.org/keen/keen-tracking.js) | ||
```html | ||
<script src="https://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.4.1.min.js"></script> | ||
<script src="https://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.4.2.min.js"></script> | ||
``` | ||
@@ -50,3 +50,3 @@ | ||
```html | ||
<script src="https://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.4.0.min.js"></script> | ||
<script src="https://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.4.2.min.js"></script> | ||
<script> | ||
@@ -53,0 +53,0 @@ Keen.ready(function(){ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
81127
1914
2
33