Skip to content

Commit 86f1ac4

Browse files
committed
Support hotpatching in web extensions
1 parent b2d01e6 commit 86f1ac4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/web/src/devtools.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,18 @@ pub(crate) fn init(config: &crate::Config) -> UnboundedReceiver<HotReloadMsg> {
4444
fn make_ws(tx: UnboundedSender<HotReloadMsg>, poll_interval: i32, reload: bool) {
4545
// Get the location of the devserver, using the current location plus the /_dioxus path
4646
// The idea here being that the devserver is always located on the /_dioxus behind a proxy
47-
let location = web_sys::window().unwrap().location();
47+
let mut location =
48+
web_sys::Url::new(&web_sys::window().unwrap().location().href().unwrap()).unwrap();
49+
if location.protocol() == "chrome-extension:" || location.protocol() == "moz-extension:" {
50+
location = web_sys::Url::new("http://localhost:8080").unwrap();
51+
}
4852
let url = format!(
4953
"{protocol}//{host}/_dioxus?build_id={build_id}",
50-
protocol = match location.protocol().unwrap() {
54+
protocol = match location.protocol() {
5155
prot if prot == "https:" => "wss:",
5256
_ => "ws:",
5357
},
54-
host = location.host().unwrap(),
58+
host = location.host(),
5559
build_id = dioxus_cli_config::build_id(),
5660
);
5761

0 commit comments

Comments
 (0)