@cloudcannon/configuration-loader 0.0.9 → 0.0.11

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 (2) hide show
  1. package/dist/load.js +13 -4
  2. package/package.json +2 -2
package/dist/load.js CHANGED
@@ -8,7 +8,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
8
8
  };
9
9
  import { globSync } from 'node:fs';
10
10
  import { readFile } from 'node:fs/promises';
11
- import { dirname, resolve } from 'node:path';
11
+ import { dirname, relative, resolve } from 'node:path';
12
12
  import { mergeConfiguration } from "./loader.js";
13
13
  /**
14
14
  * Attempts to load the js-yaml package dynamically.
@@ -86,11 +86,20 @@ export async function loadConfiguration(configPath, options) {
86
86
  // Glob operations are typically fast (just directory traversal), while file
87
87
  // reading (handled by loadConfigFile) is the slower I/O operation.
88
88
  findFilesMatchingGlobs: (globs) => {
89
- const resolvedGlobs = globs.map((g) => {
89
+ const resolvedGlobs = globs.flatMap((g) => {
90
90
  if (g.startsWith('!')) {
91
- return `!${resolve(configDir, g.slice(1))}`;
91
+ const pattern = g.slice(1);
92
+ const resolved = resolve(configDir, pattern.startsWith('/') ? pattern.slice(1) : pattern);
93
+ if (relative(configDir, resolved).startsWith('..')) {
94
+ return [];
95
+ }
96
+ return [`!${resolved}`];
92
97
  }
93
- return resolve(configDir, g);
98
+ const resolved = resolve(configDir, g.startsWith('/') ? g.slice(1) : g);
99
+ if (relative(configDir, resolved).startsWith('..')) {
100
+ return [];
101
+ }
102
+ return [resolved];
94
103
  });
95
104
  return globSync(resolvedGlobs);
96
105
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcannon/configuration-loader",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Load and merge CloudCannon configuration files",
5
5
  "type": "module",
6
6
  "engines": {
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "homepage": "https://cloudcannon.com/documentation/articles/why-split-your-configuration-file/",
54
54
  "dependencies": {
55
- "@cloudcannon/configuration-types": "0.0.58"
55
+ "@cloudcannon/configuration-types": "0.0.59"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "js-yaml": "^4.0.0"