Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Commit aa3ee5b

Browse files
committed
Revert "Replace @ndhoule/includes with lodash.includes (#211)"
This reverts commit c70c3af.
1 parent ac8f20a commit aa3ee5b

File tree

5 files changed

+43
-21
lines changed

5 files changed

+43
-21
lines changed

HISTORY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<<<<<<< HEAD
2+
13
# 4.1.7 / 2021-03-17
24

35
- Fix Potential DOM-based XSS via prototype pollution
@@ -15,6 +17,10 @@
1517

1618
- Replace `@ndhoule/includes` with `lodash.includes`
1719

20+
=======
21+
22+
> > > > > > > parent of c70c3af... Replace @ndhoule/includes with lodash.includes (#211)
23+
1824
# 4.1.3 / 2020-09-16
1925

2026
- Replace `@ndhoule/pick` with `lodash.pick`

lib/normalize.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
'use strict';
2+
13
import { Message } from './types';
2-
import includes from 'lodash.includes'
34

45
/**
56
* Module Dependencies.
67
*/
78

89
var debug = require('debug')('analytics.js:normalize');
910
var defaults = require('@ndhoule/defaults');
11+
var includes = require('@ndhoule/includes');
1012
var type = require('component-type');
1113
var uuid = require('uuid/v4');
1214
var md5 = require('spark-md5').hash;
@@ -41,14 +43,14 @@ interface NormalizedMessage {
4143
}
4244

4345
function normalize(msg: Message, list: Array<any>): NormalizedMessage {
44-
const lower = list?.map(function(s) {
46+
var lower = list?.map(function(s) {
4547
return s.toLowerCase();
4648
});
47-
const opts: Message = msg.options || {};
48-
const integrations = opts.integrations || {};
49-
const providers = opts.providers || {};
50-
const context = opts.context || {};
51-
let ret: {
49+
var opts: Message = msg.options || {};
50+
var integrations = opts.integrations || {};
51+
var providers = opts.providers || {};
52+
var context = opts.context || {};
53+
var ret: {
5254
integrations?: { [key: string]: string };
5355
context?: unknown;
5456
} = {};
@@ -74,7 +76,7 @@ function normalize(msg: Message, list: Array<any>): NormalizedMessage {
7476
// move all toplevel options to msg
7577
// and the rest to context.
7678
Object.keys(opts).forEach(key => {
77-
if (includes(toplevel, key)) {
79+
if (includes(key, toplevel)) {
7880
ret[key] = opts[key];
7981
} else {
8082
context[key] = opts[key];
@@ -94,9 +96,9 @@ function normalize(msg: Message, list: Array<any>): NormalizedMessage {
9496

9597
function integration(name: string) {
9698
return !!(
97-
includes(list, name) ||
99+
includes(name, list) ||
98100
name.toLowerCase() === 'all' ||
99-
includes(lower, name.toLowerCase())
101+
includes(name.toLowerCase(), lower)
100102
);
101103
}
102104
}

lib/pageDefaults.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
'use strict';
2+
13
import { PageDefaults } from './types';
2-
import includes from 'lodash.includes'
3-
import canonical from '@segment/canonical'
4-
import url from 'component-url'
4+
5+
/*
6+
* Module dependencies.
7+
*/
8+
9+
var canonical = require('@segment/canonical');
10+
var includes = require('@ndhoule/includes');
11+
var url = require('component-url');
512

613
/**
714
* Return a default `options.context.page` object.
@@ -24,9 +31,9 @@ function pageDefaults(): PageDefaults {
2431
*/
2532

2633
function canonicalPath(): string {
27-
const canon = canonical();
34+
var canon = canonical();
2835
if (!canon) return window.location.pathname;
29-
const parsed = url.parse(canon);
36+
var parsed = url.parse(canon);
3037
return parsed.pathname;
3138
}
3239

@@ -36,10 +43,10 @@ function canonicalPath(): string {
3643
*/
3744

3845
function canonicalUrl(search: string): string {
39-
const canon = canonical();
40-
if (canon) return includes(canon, '?') ? canon : canon + search;
41-
const url = window.location.href;
42-
const i = url.indexOf('#');
46+
var canon = canonical();
47+
if (canon) return includes('?', canon) ? canon : canon + search;
48+
var url = window.location.href;
49+
var i = url.indexOf('#');
4350
return i === -1 ? url : url.slice(0, i);
4451
}
4552

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@segment/analytics.js-core",
33
"author": "Segment <[email protected]>",
4-
"version": "4.1.4",
4+
"version": "4.1.3",
55
"description": "The hassle-free way to integrate analytics into any web application.",
66
"types": "lib/index.d.ts",
77
"keywords": [
@@ -31,6 +31,7 @@
3131
"homepage": "https://github.com/segmentio/analytics.js-core#readme",
3232
"dependencies": {
3333
"@ndhoule/defaults": "^2.0.1",
34+
"@ndhoule/includes": "^2.0.1",
3435
"@segment/canonical": "^1.0.0",
3536
"@segment/cookie": "^1.1.5",
3637
"@segment/is-meta": "^1.0.0",
@@ -52,7 +53,6 @@
5253
"is": "^3.1.0",
5354
"lodash.assignin": "^4.2.0",
5455
"lodash.clonedeep": "^4.5.0",
55-
"lodash.includes": "^4.3.0",
5656
"lodash.pick": "^4.4.0",
5757
"new-date": "^1.0.0",
5858
"next-tick": "^0.2.2",

yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6440,6 +6440,7 @@ lodash.has@^4.5.2:
64406440
resolved "https://registry.yarnpkg.com/lodash.has/-/lodash.has-4.5.2.tgz#d19f4dc1095058cccbe2b0cdf4ee0fe4aa37c862"
64416441
integrity sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI=
64426442

6443+
<<<<<<< HEAD
64436444
lodash.includes@^4.3.0:
64446445
version "4.3.0"
64456446
resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f"
@@ -6454,6 +6455,12 @@ lodash.isboolean@^3.0.3:
64546455
version "3.0.3"
64556456
resolved "https://registry.yarnpkg.com/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz#6c2e171db2a257cd96802fd43b01b20d5f5870f6"
64566457
integrity sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY=
6458+
=======
6459+
lodash.isarray@^4.0.0:
6460+
version "4.0.0"
6461+
resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-4.0.0.tgz#2aca496b28c4ca6d726715313590c02e6ea34403"
6462+
integrity sha1-KspJayjEym1yZxUxNZDALm6jRAM=
6463+
>>>>>>> parent of c70c3af... Replace @ndhoule/includes with lodash.includes (#211)
64576464

64586465
lodash.isempty@^4.4.0:
64596466
version "4.4.0"

0 commit comments

Comments
 (0)