Skip to content

Commit

Permalink
Remove cookie dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
flosse committed Mar 4, 2023
1 parent 0009523 commit 55d09b9
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 62 deletions.
41 changes: 1 addition & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Expand Up @@ -63,7 +63,6 @@ exclude = [
]

[dependencies]
cookie = { version = "0.16.2", features = ["percent-encode"] }
# @TODO: remove once we can use entities without `Debug` in `log!` and `error!` on `stable` Rust.
# https://github.com/Centril/rfcs/blob/rfc/quick-debug-macro/text/0000-quick-debug-macro.md#types-which-are-not-debug
dbg = "1.0.4"
Expand Down
19 changes: 0 additions & 19 deletions src/browser/util.rs
Expand Up @@ -60,25 +60,6 @@ pub fn canvas_context_2d(canvas: &web_sys::HtmlCanvasElement) -> web_sys::Canvas
.expect("Problem casting as web_sys::CanvasRenderingContext2d")
}

/// Convenience function to get all cookies from the current `HtmlDocument`
/// _Note:_ Returns `None` if parsing cookies fails or there are no cookies.
pub fn cookies() -> Option<cookie::CookieJar> {
let cookies_str = html_document().cookie().ok()?;
let mut jar = cookie::CookieJar::new();

for cookie_str in cookies_str.split(';') {
let cookie = cookie::Cookie::parse_encoded(cookie_str).ok()?;
jar.add(cookie.into_owned());
}

let jar_is_empty = jar.iter().next().is_none();
if jar_is_empty {
None
} else {
Some(jar)
}
}

#[deprecated(
since = "0.8.0",
note = "use [`Orders::after_next_render`](../../app/orders/trait.Orders.html#method.after_next_render) instead"
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Expand Up @@ -97,8 +97,7 @@ pub use crate::{
},
browser::url::Url,
browser::util::{
self, body, canvas, canvas_context_2d, cookies, document, error, history, html_document,
log, window,
self, body, canvas, canvas_context_2d, document, error, history, html_document, log, window,
},
virtual_dom::{Attrs, EventHandler, Style},
};
Expand Down

0 comments on commit 55d09b9

Please sign in to comment.