@bonniernews/local-esi
Advanced tools
Comparing version 2.1.1 to 2.1.2
@@ -11,2 +11,7 @@ Changelog | ||
## [2.1.2] - 2022-03-03 | ||
### Fixed | ||
- Throw error if esi:choose has other direct children than esi:when and esi:otherwise | ||
## [2.1.1] - 2021-12-20 | ||
@@ -13,0 +18,0 @@ |
@@ -40,2 +40,7 @@ /* eslint-disable no-use-before-define */ | ||
class ESIChoose extends ESITag { | ||
assert(name) { | ||
if (![ "esi:when", "esi:otherwise" ].includes(name)) { | ||
throw new Error(`${name} is not allowed inside a esi:choose`); | ||
} | ||
} | ||
open(data, next) { | ||
@@ -247,3 +252,12 @@ this.context.chooses.push({ testMatched: false, chosen: false }); | ||
if (Tag) esiFunc = new Tag(context); | ||
context.tags.push(esiFunc); | ||
const tags = context.tags; | ||
const idx = context.tags.push(esiFunc); | ||
const parent = tags[idx - 2]; | ||
if (parent?.assert) { | ||
try { | ||
parent.assert(name); | ||
} catch (err) { | ||
return next(err); | ||
} | ||
} | ||
if (!wasInPlainText) return esiFunc.open(data, next); | ||
@@ -250,0 +264,0 @@ } |
{ | ||
"name": "@bonniernews/local-esi", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "Local Edge Side Includes parser", | ||
@@ -21,10 +21,10 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@bonniernews/atlas-html-stream": "^2.0.0", | ||
"chai": "^4.3.4", | ||
"@bonniernews/atlas-html-stream": "^2.0.1", | ||
"chai": "^4.3.6", | ||
"chronokinesis": "^3.1.2", | ||
"eslint": "^8.5.0", | ||
"eslint": "^8.10.0", | ||
"eslint-config-exp": "0.0.9", | ||
"got": "^11.8.3", | ||
"mocha": "^9.1.3", | ||
"nock": "^13.2.1" | ||
"mocha": "^9.2.1", | ||
"nock": "^13.2.4" | ||
}, | ||
@@ -31,0 +31,0 @@ "engines": { |
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
53851
1617