Skip to content

Commit 9e5e5e9

Browse files
committed
only block registration when appRoute contains the exact basePath (#67125)
1 parent 6e5e788 commit 9e5e5e9

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/core/public/application/application_service.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ describe('#setup()', () => {
174174
).toThrowErrorMatchingInlineSnapshot(
175175
`"Cannot register an application route that includes HTTP base path"`
176176
);
177+
178+
expect(() =>
179+
register(Symbol(), createApp({ id: 'app3', appRoute: '/base-path-i-am-not' }))
180+
).not.toThrow();
177181
});
178182
});
179183

src/core/public/application/application_service.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export class ApplicationService {
179179
throw new Error(
180180
`An application is already registered with the appRoute "${app.appRoute}"`
181181
);
182-
} else if (basename && app.appRoute!.startsWith(basename)) {
182+
} else if (basename && app.appRoute!.startsWith(`${basename}/`)) {
183183
throw new Error('Cannot register an application route that includes HTTP base path');
184184
}
185185

@@ -208,7 +208,7 @@ export class ApplicationService {
208208
throw new Error('Applications cannot be registered after "setup"');
209209
} else if (this.apps.has(app.id)) {
210210
throw new Error(`An application is already registered with the id "${app.id}"`);
211-
} else if (basename && appRoute!.startsWith(basename)) {
211+
} else if (basename && appRoute!.startsWith(`${basename}/`)) {
212212
throw new Error('Cannot register an application route that includes HTTP base path');
213213
}
214214

0 commit comments

Comments
 (0)