Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
source.refHash = simpleHash(page.ref);
// Direct with marks -> campaign
// Direct with fbclid -> facebooj social
if (ref === '') {
if (has_utm || has_os || has_gclid || has_yclid) {
source.type = SESSION_CAMPAIGN;
}
if(has_fbclid){
source.type = SESSION_SOCIAL
source.engine = ENGINE_FACEBOOK
}
return source;
}
source.refhost = punycode.toUnicode(removeWww(ref.hostname));
// Internal
if (ref && source.refhost === removeWww(page.domain)) {
log('internal detect', ref, source.refhost, removeWww(page.hostname))
source.type = source.hasMarks ? SESSION_CAMPAIGN : SESSION_INTERNAL;
return source;
}
// Other types: campaigns, organic, social
const refDomainParts = source.refhost.split('.').reverse();
for (let i = 0; i < RULES.length; i++) {
const rule = RULES[i];
const ruleDomainParts = rule.domain.split('.').reverse();
const refDomainPartsClone = refDomainParts.slice();
function normalizeLinkText(url) {
var parsed = mdurl.parse(url, true);
if (parsed.hostname) {
// Encode hostnames in urls like:
// `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
//
// We don't encode unknown schemas, because it's likely that we encode
// something we shouldn't (e.g. `skype:name` treated as `skype:host`)
//
if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
try {
parsed.hostname = punycode.toUnicode(parsed.hostname);
} catch (er) { /**/ }
}
}
return mdurl.decode(mdurl.format(parsed));
}
}
} else if (index[partstr]) { // exact match, not exception
suffixLen = i+1;
}
suffix = '.'+partstr;
}
if (index['*'+suffix]) { // *.domain exists (e.g. *.kyoto.jp for domain='kyoto.jp');
return null;
}
suffixLen = suffixLen || 1;
if (parts.length > suffixLen) {
var publicSuffix = parts.slice(0,suffixLen+1).reverse().join('.');
return converted ? punycode.toUnicode(publicSuffix) : publicSuffix;
}
return null;
}
function normalizeLinkText(url) {
var parsed = mdurl.parse(url, true);
if (parsed.hostname) {
// Encode hostnames in urls like:
// `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
//
// We don't encode unknown schemas, because it's likely that we encode
// something we shouldn't (e.g. `skype:name` treated as `skype:host`)
//
if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
try {
parsed.hostname = punycode.toUnicode(parsed.hostname);
} catch (er) {/**/}
}
}
return mdurl.decode(mdurl.format(parsed));
}
const uriTokens = [];
//find scheme handler
const schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
//perform scheme specific serialization
if (schemeHandler && schemeHandler.serialize)
schemeHandler.serialize(components, options);
if (components.host) {
//if host component is an IPv6 address
if (protocol.IPV6ADDRESS.test(components.host)) {
//TODO: normalize IPv6 address as per RFC 5952
}
//if host component is a domain name
else if (options.domainHost || (schemeHandler && schemeHandler.domainHost)) {
//convert IDN via punycode
try {
components.host = (!options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host));
}
catch (e) {
components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
}
}
}
//normalize encoding
_normalizeComponentEncoding(components, protocol);
if (options.reference !== "suffix" && components.scheme) {
uriTokens.push(components.scheme);
uriTokens.push(":");
}
const authority = _recomposeAuthority(components, options);
if (authority !== undefined) {
if (options.reference !== "suffix") {
uriTokens.push("//");
const uriTokens = [];
//find scheme handler
const schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
//perform scheme specific serialization
if (schemeHandler && schemeHandler.serialize)
schemeHandler.serialize(components, options);
if (components.host) {
//if host component is an IPv6 address
if (protocol.IPV6ADDRESS.test(components.host)) {
//TODO: normalize IPv6 address as per RFC 5952
}
//if host component is a domain name
else if (options.domainHost || (schemeHandler && schemeHandler.domainHost)) {
//convert IDN via punycode
try {
components.host = (!options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host));
}
catch (e) {
components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
}
}
}
//normalize encoding
_normalizeComponentEncoding(components, protocol);
if (options.reference !== "suffix" && components.scheme) {
uriTokens.push(components.scheme);
uriTokens.push(":");
}
const authority = _recomposeAuthority(components, options);
if (authority !== undefined) {
if (options.reference !== "suffix") {
uriTokens.push("//");
function usingPunycode(val) {
punycode.toUnicode(punycode.toASCII(val));
}
function decodePuny(ascii) {
return punycode.toUnicode(ascii);
}
const parseUrl = url => {
try {
return punycode.toUnicode(url);
} catch (e) {
return url;
}
};
availableDomains: data.options.map((domain) => ({
name: domain,
displayName: punycode.toUnicode(domain),
formattedName: punycode.toUnicode(domain),
})),
availableJoinRestrictions: data.models[