Comparing version 2.1.2 to 2.2.0
{ | ||
"name": "chai", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -0,1 +1,12 @@ | ||
2.2.0 / 2015-03-26 | ||
================== | ||
* Merge pull request #405 from chaijs/deep-escape-doc-tweaks | ||
* Tweak documentation on `.deep` flag. | ||
* Merge pull request #402 from umireon/escaping-dot-should-be-taken | ||
* Documentation of escaping in `.deep` flag. | ||
* take regular expression apart | ||
* Feature: backslash-escaping in `.deep.property` | ||
* Escaping dot should be taken in deep property | ||
2.1.2 / 2015-03-15 | ||
@@ -2,0 +13,0 @@ ================== |
@@ -14,3 +14,3 @@ /*! | ||
exports.version = '2.1.2'; | ||
exports.version = '2.2.0'; | ||
@@ -17,0 +17,0 @@ /*! |
@@ -78,2 +78,8 @@ /*! | ||
* | ||
* `.deep.property` special characters can be escaped | ||
* by adding two slashes before the `.` or `[]`. | ||
* | ||
* var deepCss = { '.link': { '[target]': 42 }}; | ||
* expect(deepCss).to.have.deep.property('\\.link.\\[target\\]', 42); | ||
* | ||
* @name deep | ||
@@ -765,3 +771,3 @@ * @api public | ||
* }; | ||
* | ||
* expect(deepObj).to.have.deep.property('green.tea', 'matcha'); | ||
@@ -798,2 +804,14 @@ * expect(deepObj).to.have.deep.property('teas[1]', 'matcha'); | ||
* | ||
* Note that dots and bracket in `name` must be backslash-escaped when | ||
* the `deep` flag is set, while they must NOT be escaped when the `deep` | ||
* flag is not set. | ||
* | ||
* // simple referencing | ||
* var css = { '.link[target]': 42 }; | ||
* expect(css).to.have.property('.link[target]', 42); | ||
* | ||
* // deep referencing | ||
* var deepCss = { '.link': { '[target]': 42 }}; | ||
* expect(deepCss).to.have.deep.property('\\.link.\\[target\\]', 42); | ||
* | ||
* @name property | ||
@@ -800,0 +818,0 @@ * @alias deep.property |
@@ -57,2 +57,3 @@ /*! | ||
* * Arrays are also valid using the formal `myobject.document[3].property`. | ||
* * Literal dots and brackets (not delimiter) must be backslash-escaped. | ||
* | ||
@@ -65,9 +66,9 @@ * @param {String} path | ||
function parsePath (path) { | ||
var str = path.replace(/\[/g, '.[') | ||
var str = path.replace(/([^\\])\[/g, '$1.[') | ||
, parts = str.match(/(\\\.|[^.]+?)+/g); | ||
return parts.map(function (value) { | ||
var re = /\[(\d+)\]$/ | ||
var re = /^\[(\d+)\]$/ | ||
, mArr = re.exec(value); | ||
if (mArr) return { i: parseFloat(mArr[1]) }; | ||
else return { p: value }; | ||
else return { p: value.replace(/\\([.\[\]])/g, '$1') }; | ||
}); | ||
@@ -74,0 +75,0 @@ } |
@@ -20,3 +20,3 @@ { | ||
], | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"repository": { | ||
@@ -23,0 +23,0 @@ "type": "git", |
# Release Notes | ||
## 2.2.0 / 2015-03-26 | ||
Deep property strings can now be escaped using `\\` - for example: | ||
```js | ||
var deepCss = { '.link': { '[target]': 42 }}; | ||
expect(deepCss).to.have.deep.property('\\.link.\\[target\\]', 42) | ||
``` | ||
### Community Contributions | ||
#### Code Features & Fixes | ||
* [#402](https://github.com/chaijs/chai/pull/402) Allow escaping of deep | ||
property keys. | ||
By [@umireon](https://github.com/umireon) | ||
#### Documentation fixes | ||
* [#405](https://github.com/chaijs/chai/pull/405) Tweak documentation around | ||
deep property escaping. | ||
By [@keithamus](https://github.com/keithamus) | ||
## 2.1.2 / 2015-03-15 | ||
@@ -4,0 +28,0 @@ |
Sorry, the diff of this file is too big to display
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
342480
8958
0