Skip to content

Commit ad5b431

Browse files
authored
Merge pull request #484 from sujeffreyl/makeDownloadAvailableInAppHosted
Fix app-hosted detection in /#!/app-hosted intermediate stage.
2 parents 14c3599 + a5e286e commit ad5b431

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/components/appHosted/AppHostedUtils.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,23 @@ export const appHostedSegment = "app-hosted-v1";
1313
// We deliberately don't check the version, though eventually, if we need another version,
1414
// something will presumably notice the difference.
1515
export function useIsAppHosted() {
16+
// Note: While the SPA is changing the history state, an intermediate URL is "/#!/app-hosted-[...]".
17+
// The path is technically "/", not "/app-hosted", but we want to detect that as app-hosted too.
18+
// (Probably not too likely to happen in this hook version)
1619
const location = useLocation();
17-
return location.pathname.startsWith("/app-hosted-");
20+
return (
21+
location.pathname.startsWith("/app-hosted-") ||
22+
location.pathname.startsWith("/#!/app-hosted-")
23+
);
1824
}
1925
export function isAppHosted() {
20-
return window.location.pathname.startsWith("/app-hosted-");
26+
// Note: While the SPA is changing the history state, an intermediate URL is "/#!/app-hosted-[...]".
27+
// The path is technically "/", not "/app-hosted", but we want to detect that as app-hosted too.
28+
// This is a very real possibility for context providers like OSFeaturesContext.
29+
return (
30+
window.location.pathname.startsWith("/app-hosted-") ||
31+
window.location.pathname.startsWith("/#!/app-hosted-")
32+
);
2133
}
2234

2335
// Return the equivalent URL path not in the app-hosted space.

0 commit comments

Comments
 (0)