@netlify/config 24.2.0 → 24.3.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 (2) hide show
  1. package/lib/context.js +21 -1
  2. package/package.json +3 -3
package/lib/context.js CHANGED
@@ -26,9 +26,29 @@ export const mergeContext = function ({ config: { context: contextProps, ...conf
26
26
  }
27
27
  const contexts = [context, branch];
28
28
  validateContextsPluginsConfig({ contextProps, plugins, contexts, logs });
29
- const filteredContextProps = contexts.map((key) => contextProps[key]).filter(Boolean);
29
+ const filteredContextProps = contexts.flatMap((key) => findMatchingContextProps(contextProps, key)).filter(Boolean);
30
30
  return mergeConfigs([config, ...filteredContextProps]);
31
31
  };
32
+ // Find matching context properties for a given key.
33
+ // First tries exact match, then falls back to wildcard pattern matching.
34
+ // Wildcard patterns use prefix matching with '*' suffix (e.g., "feat/*" matches "feat/my-branch").
35
+ const findMatchingContextProps = function (contextProps, key) {
36
+ if (!key) {
37
+ return [];
38
+ }
39
+ // Exact match takes precedence
40
+ if (contextProps[key]) {
41
+ return [contextProps[key]];
42
+ }
43
+ // Fall back to wildcard pattern matching
44
+ const matchingProps = [];
45
+ for (const [pattern, value] of Object.entries(contextProps)) {
46
+ if (pattern.endsWith('*') && key.startsWith(pattern.slice(0, -1))) {
47
+ matchingProps.push(value);
48
+ }
49
+ }
50
+ return matchingProps;
51
+ };
32
52
  // `config.context.{context}.*` properties are merged either to `config.*` or
33
53
  // to `config.build.*`. We distinguish between both by checking the property
34
54
  // name.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/config",
3
- "version": "24.2.0",
3
+ "version": "24.3.0",
4
4
  "description": "Netlify config module",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -59,7 +59,7 @@
59
59
  "license": "MIT",
60
60
  "dependencies": {
61
61
  "@iarna/toml": "^2.2.5",
62
- "@netlify/api": "^14.0.12",
62
+ "@netlify/api": "^14.0.13",
63
63
  "@netlify/headers-parser": "^9.0.2",
64
64
  "@netlify/redirect-parser": "^15.0.3",
65
65
  "chalk": "^5.0.0",
@@ -96,5 +96,5 @@
96
96
  "engines": {
97
97
  "node": ">=18.14.0"
98
98
  },
99
- "gitHead": "c8f9389ddbcd5cde46cc3d03f2547681b8114043"
99
+ "gitHead": "b361a613025153da728f16946fb3e2f784127d1a"
100
100
  }