Skip to content

Commit

Permalink
handle uptime app special case
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Aug 27, 2020
1 parent df3502b commit a4a2bed
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/core/public/application/ui/app_router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ export const AppRouter: FunctionComponent<Props> = ({
url,
},
}: RouteComponentProps<Params>) => {
const [id, mounter] = mounters.has(appId) ? [appId, mounters.get(appId)] : [];
return (
<AppContainer
appPath={url}
appId={appId}
appId={id ?? appId}
appStatus={appStatuses.get(appId) ?? AppStatus.inaccessible}
createScopedHistory={createScopedHistory}
mounter={undefined}
mounter={mounter}
{...{ setAppLeaveHandler, setIsMounting }}
/>
);
Expand Down
4 changes: 3 additions & 1 deletion src/core/public/application/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ describe('appendAppPath', () => {
expect(appendAppPath('/app/my-app', '')).toEqual('/app/my-app');
});

it('preserves the trailing slash only if included in the hash', () => {
it('preserves the trailing slash only if included in the hash or appPath', () => {
expect(appendAppPath('/app/my-app', '/some-path/')).toEqual('/app/my-app/some-path');
expect(appendAppPath('/app/my-app', '/some-path#/')).toEqual('/app/my-app/some-path#/');
expect(appendAppPath('/app/my-app#/', '')).toEqual('/app/my-app#/');
expect(appendAppPath('/app/my-app#', '/')).toEqual('/app/my-app#/');
expect(appendAppPath('/app/my-app', '/some-path#/hash/')).toEqual(
'/app/my-app/some-path#/hash/'
);
Expand Down
4 changes: 2 additions & 2 deletions src/core/public/application/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export const removeSlashes = (
export const appendAppPath = (appBasePath: string, path: string = '') => {
// Only prepend slash if not a hash or query path
path = path === '' || path.startsWith('#') || path.startsWith('?') ? path : `/${path}`;
// Do not remove trailing slash when in hashbang
const removeTrailing = path.indexOf('#') === -1;
// Do not remove trailing slash when in hashbang or basePath
const removeTrailing = path.indexOf('#') === -1 && appBasePath.indexOf('#') === -1;
return removeSlashes(`${appBasePath}${path}`, {
trailing: removeTrailing,
duplicates: true,
Expand Down

0 comments on commit a4a2bed

Please sign in to comment.