Skip to content

Commit fbbf615

Browse files
committed
refactor: optimize populateWebAppBundle logic
- Reduced path splitting from 3 times to 1 time - Removed unused pathParts variable - Improved code clarity with inline comments
1 parent 4d658b5 commit fbbf615

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/resolve/adapters/digitalExperienceSourceAdapter.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,24 @@ export class DigitalExperienceSourceAdapter extends BundleSourceAdapter {
197197
if (component) {
198198
return component;
199199
}
200-
const bundleName = this.getBundleName(trigger);
200+
201201
const pathParts = trigger.split(sep);
202-
const bundleDir = pathParts.slice(0, getDigitalExperiencesIndex(trigger) + 3).join(sep);
202+
const digitalExperiencesIndex = pathParts.indexOf('digitalExperiences');
203+
204+
// Extract bundle name: web_app/WebApp3
205+
const baseType = pathParts[digitalExperiencesIndex + 1];
206+
const spaceApiName = pathParts[digitalExperiencesIndex + 2];
207+
const bundleName = `${baseType}/${spaceApiName}`;
208+
209+
// Extract bundle directory: /path/to/digitalExperiences/web_app/WebApp3
210+
const bundleDir = pathParts.slice(0, digitalExperiencesIndex + 3).join(sep);
211+
212+
// Get the DigitalExperienceBundle type
203213
const parentType = this.isBundleType() ? this.type : this.registry.getParentType(this.type.id);
204214
if (!parentType) {
205215
throw messages.createError('error_failed_convert', [bundleName]);
206216
}
217+
207218
return new SourceComponent(
208219
{
209220
name: bundleName,

0 commit comments

Comments
 (0)