apostrophe 2.221.2 → 2.222.0

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/index.js +7 -9
  3. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.222.0 (2022-07-20)
4
+
5
+ ## Adds
6
+
7
+ * `testModule: true` is now compatible with `mocha` 10.x as well as previously supported versions of `mocha`. Thanks to [Amin Shazrin](https://github.com/ammein) for this contribution.
8
+
9
+ ## Fixes
10
+
11
+ * `sanitize-html` dependency bumped to ensure a potential denial-of-service vector is closed.
12
+
3
13
  ## 2.221.2 (2022-07-06)
4
14
 
5
15
  ## Fixes
package/index.js CHANGED
@@ -256,7 +256,7 @@ module.exports = function(options) {
256
256
  while (m.parent) {
257
257
  // The test file is the root as far as we are concerned,
258
258
  // not mocha itself
259
- if (m.parent.filename.match(/\/node_modules\/mocha\//)) {
259
+ if (m.parent.filename.match(new RegExp(`${path.sep}node_modules${path.sep}mocha${path.sep}`))) {
260
260
  return m;
261
261
  }
262
262
  m = m.parent;
@@ -415,20 +415,18 @@ module.exports = function(options) {
415
415
  // and throws an exception if we don't
416
416
  function findTestModule() {
417
417
  var m = module;
418
- var nodeModuleRegex;
419
- if (process.platform === "win32") {
420
- nodeModuleRegex = /node_modules\\mocha/;
421
- } else {
422
- nodeModuleRegex = /node_modules\/mocha/;
418
+ var nodeModuleRegex = new RegExp("node_modules" + path.sep + "mocha");
419
+ if (!require.main.filename.match(nodeModuleRegex)) {
420
+ throw new Error('mocha does not seem to be running, is this really a test?');
423
421
  }
424
422
  while (m) {
425
423
  if (m.parent && m.parent.filename.match(nodeModuleRegex)) {
426
424
  return m;
425
+ } else if (!m.parent) {
426
+ // Mocha v10 doesn't inject mocha paths inside `module`, therefore, we only detect the parent until the last parent. But we can get Mocha running using `require.main` - Amin
427
+ return m;
427
428
  }
428
429
  m = m.parent;
429
- if (!m) {
430
- throw new Error('mocha does not seem to be running, is this really a test?');
431
- }
432
430
  }
433
431
  }
434
432
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apostrophe",
3
- "version": "2.221.2",
3
+ "version": "2.222.0",
4
4
  "description": "The Apostrophe Content Management System.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -72,7 +72,7 @@
72
72
  "request-promise": "^4.2.4",
73
73
  "resolve": "^1.20.0",
74
74
  "rimraf": "^2.7.1",
75
- "sanitize-html": "^2.4.0",
75
+ "sanitize-html": "^2.7.1",
76
76
  "server-destroy": "^1.0.1",
77
77
  "sluggo": "^0.2.0",
78
78
  "syntax-error": "^1.3.0",