@adobe-commerce/elsie 1.5.0-alpha1 → 1.5.0-alpha100

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe-commerce/elsie",
3
- "version": "1.5.0-alpha1",
3
+ "version": "1.5.0-alpha100",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "description": "Domain Package SDK",
6
6
  "engines": {
@@ -40,7 +40,7 @@ function resetConfig() {
40
40
  * @param {Object} [configObj=config] - The config object.
41
41
  * @returns {string} - The root path.
42
42
  */
43
- function getRootPath(configObj: Config | null = config): string {
43
+ function getRootPath(configObj: Config | null = config, options: { match?: (key: string) => boolean }): string {
44
44
  if (!configObj) {
45
45
  console.warn('No config found. Please call initializeConfig() first.');
46
46
  return '/';
@@ -56,7 +56,7 @@ function getRootPath(configObj: Config | null = config): string {
56
56
  .find(
57
57
  (key) =>
58
58
  window.location.pathname === key ||
59
- window.location.pathname.startsWith(key)
59
+ (options?.match?.(key) ?? window.location.pathname.startsWith(key))
60
60
  );
61
61
 
62
62
  return value ?? '/';
@@ -126,11 +126,14 @@ function applyConfigOverrides(
126
126
 
127
127
  /**
128
128
  * Initializes the configuration system.
129
+ * @param {Object} configObj - The config object.
130
+ * @param {Object} [options] - The options object.
131
+ * @param {Function} [options.match] - The function to match the path to the config.
129
132
  * @returns {Object} The initialized root configuration
130
133
  */
131
- function initializeConfig(configObj: Config): ConfigRoot {
134
+ function initializeConfig(configObj: Config, options?: { match?: (key: string) => boolean }): ConfigRoot {
132
135
  config = configObj;
133
- rootPath = getRootPath(config);
136
+ rootPath = getRootPath(config, { match: options?.match });
134
137
  rootConfig = applyConfigOverrides(config, rootPath);
135
138
  return rootConfig;
136
139
  }