route work

This commit is contained in:
John Smith
2022-12-19 17:01:42 -05:00
parent dc1a27c0a0
commit ee30f19ecf
4 changed files with 52 additions and 3 deletions
+9 -2
View File
@@ -21,7 +21,7 @@ pub fn is_browser() -> bool {
return cache != 0;
}
let res = Reflect::has(&global().as_ref(), &"window".into()).unwrap_or_default();
let res = Reflect::has(&global().as_ref(), &"navigator".into()).unwrap_or_default();
CACHE.store(res as i8, Ordering::Relaxed);
@@ -35,7 +35,7 @@ pub fn is_browser_https() -> bool {
return cache != 0;
}
let res = js_sys::eval("window.location.protocol === 'https'")
let res = js_sys::eval("self.location.protocol === 'https'")
.map(|res| res.is_truthy())
.unwrap_or_default();
@@ -44,6 +44,13 @@ pub fn is_browser_https() -> bool {
res
}
pub fn get_wasm_global_string_value<K: AsRef<str>>(key: K) -> Option<String> {
let Ok(v) = Reflect::get(&global().as_ref(), &JsValue::from_str(key.as_ref())) else {
return None;
};
v.as_string()
}
#[derive(ThisError, Debug, Clone, Eq, PartialEq)]
#[error("JsValue error")]
pub struct JsValueError(String);