bson 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/HISTORY.md CHANGED
@@ -1,3 +1,14 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### [1.1.5](https://github.com/mongodb/js-bson/compare/v1.1.4...v1.1.5) (2020-08-10)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **object-id:** harden the duck-typing ([b526145](https://github.com/mongodb/js-bson/commit/b5261450c3bc4abb2e2fb19b5b1a7aba27982d44))
11
+
1
12
  <a name="1.1.3"></a>
2
13
  ## [1.1.3](https://github.com/mongodb/js-bson/compare/v1.1.2...v1.1.3) (2019-11-09)
3
14
 
package/bower.json CHANGED
@@ -21,5 +21,6 @@
21
21
  "node_modules",
22
22
  "test",
23
23
  "tools"
24
- ]
24
+ ],
25
+ "version": "1.1.5"
25
26
  }
@@ -66,7 +66,7 @@ var ObjectID = function ObjectID(id) {
66
66
  } else if (id != null && id.length === 12) {
67
67
  // assume 12 byte string
68
68
  this.id = id;
69
- } else if (id != null && id.toHexString) {
69
+ } else if (id != null && typeof id.toHexString === 'function') {
70
70
  // Duck-typing to support ObjectId from different npm packages
71
71
  return id;
72
72
  } else {
@@ -357,7 +357,10 @@ ObjectID.isValid = function isValid(id) {
357
357
  }
358
358
 
359
359
  // Duck-Typing detection of ObjectId like objects
360
- if (id.toHexString) {
360
+ if (
361
+ typeof id.toHexString === 'function' &&
362
+ (id.id instanceof _Buffer || typeof id.id === 'string')
363
+ ) {
361
364
  return id.id.length === 12 || (id.id.length === 24 && checkForHexRegExp.test(id.id));
362
365
  }
363
366
 
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "browser_build",
13
13
  "bower.json"
14
14
  ],
15
- "version": "1.1.4",
15
+ "version": "1.1.5",
16
16
  "author": "Christian Amor Kvalheim <christkv@gmail.com>",
17
17
  "contributors": [],
18
18
  "repository": "mongodb/js-bson",
@@ -31,6 +31,7 @@
31
31
  "babel-preset-stage-0": "^6.5.0",
32
32
  "babel-register": "^6.14.0",
33
33
  "conventional-changelog-cli": "^1.3.5",
34
+ "standard-version": "^7.1.0",
34
35
  "webpack": "^1.13.2",
35
36
  "webpack-polyfills-plugin": "0.0.9"
36
37
  },
@@ -49,7 +50,8 @@
49
50
  "build": "webpack --config ./webpack.dist.config.js",
50
51
  "changelog": "conventional-changelog -p angular -i HISTORY.md -s",
51
52
  "lint": "eslint lib test",
52
- "format": "prettier --print-width 100 --tab-width 2 --single-quote --write 'test/**/*.js' 'lib/**/*.js'"
53
+ "format": "prettier --print-width 100 --tab-width 2 --single-quote --write 'test/**/*.js' 'lib/**/*.js'",
54
+ "release": "standard-version -i HISTORY.md"
53
55
  },
54
56
  "browser": "lib/bson/bson.js",
55
57
  "license": "Apache-2.0"