Skip to content

Commit 81598fd

Browse files
committed
fix test: updating web/index.html
1 parent b4a39f6 commit 81598fd

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

web/404.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Redirecting...</title>
6+
<script type="text/javascript">
7+
// Get the current path from the URL.
8+
var path = window.location.pathname;
9+
10+
// Get any search query parameters.
11+
var search = window.location.search;
12+
13+
// Preserve the path and search query, but redirect using a hash.
14+
// This tricks the GitHub Pages server into loading the index.html
15+
// and lets the Flutter router handle the deep link.
16+
window.location.href = '/?' +
17+
'redirect=' + encodeURIComponent(path.substr(1) + search);
18+
</script>
19+
</head>
20+
<body>
21+
</body>
22+
</html>

web/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4+
<script>
5+
(function () {
6+
// Look for the redirect parameter in the URL.
7+
var params = new URLSearchParams(window.location.search);
8+
var redirect = params.get('redirect');
9+
10+
if (redirect) {
11+
// If a redirect path is found, replace the current history state
12+
// with the correct path, so the Flutter router can handle it.
13+
// We use replaceState to avoid breaking the browser's back button.
14+
window.history.replaceState(null, null, redirect);
15+
}
16+
})();
17+
</script>
18+
419
<!--
520
If you are serving your web app in a path other than the root, change the
621
href value below to reflect the base path you are serving from.

0 commit comments

Comments
 (0)