Skip to content

Commit 1838abb

Browse files
authored
Merge pull request #485 from sujeffreyl/makeDownloadAvailableInAppHosted
Fix bug in detecting /#!/app-hosted (#485)
2 parents ad5b431 + 13aadb5 commit 1838abb

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/components/appHosted/AppHostedUtils.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,23 @@ export const appHostedSegment = "app-hosted-v1";
1414
// something will presumably notice the difference.
1515
export function useIsAppHosted() {
1616
// 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.
17+
// The path is technically "/", not "/app-hosted-[...]", but we want to detect that as app-hosted too.
1818
// (Probably not too likely to happen in this hook version)
1919
const location = useLocation();
2020
return (
2121
location.pathname.startsWith("/app-hosted-") ||
22-
location.pathname.startsWith("/#!/app-hosted-")
22+
(location.pathname === "/" &&
23+
location.hash.startsWith("#!/app-hosted-"))
2324
);
2425
}
2526
export function isAppHosted() {
2627
// 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+
// The path is technically "/", not "/app-hosted-[...]", but we want to detect that as app-hosted too.
2829
// This is a very real possibility for context providers like OSFeaturesContext.
2930
return (
3031
window.location.pathname.startsWith("/app-hosted-") ||
31-
window.location.pathname.startsWith("/#!/app-hosted-")
32+
(window.location.pathname === "/" &&
33+
window.location.hash.startsWith("#!/app-hosted-"))
3234
);
3335
}
3436

0 commit comments

Comments
 (0)