Skip to content

Commit 96d3bda

Browse files
authored
Web: Add basepath to UnityLibrary URI (#865)
1 parent 6ac1561 commit 96d3bda

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/src/web/web_unity_widget_view.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class WebUnityWidgetView extends StatefulWidget {
1818
class _WebUnityWidgetViewState extends State<WebUnityWidgetView> {
1919
final WebViewController _controller = WebViewController()
2020
..loadRequest(
21-
Uri.parse('${Uri.base.origin}/UnityLibrary/index.html'),
21+
Uri.parse('${_getBasePath()}/UnityLibrary/index.html'),
2222
);
2323

2424
@override
@@ -36,4 +36,10 @@ class _WebUnityWidgetViewState extends State<WebUnityWidgetView> {
3636
Widget build(BuildContext context) {
3737
return WebViewWidget(controller: _controller);
3838
}
39+
40+
static String _getBasePath() {
41+
var prefix = Uri.base.origin+Uri.base.path;
42+
if (prefix.endsWith("/")) prefix = prefix.substring(0, prefix.length - 1);
43+
return prefix;
44+
}
3945
}

0 commit comments

Comments
 (0)