Skip to content

Commit

Permalink
web: use document link as base for <link> element
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwuelker committed Jul 27, 2024
1 parent c8a5ce4 commit ec85c80
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/web/src/dom/dom_objects/html_link_element.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::str::FromStr;

use dom_derive::inherit;
use url::URL;

Expand Down Expand Up @@ -29,12 +27,14 @@ impl HtmlLinkElement {

#[must_use]
pub fn url(&self) -> Option<URL> {
let document = self.owning_document().expect("must have a document");

self.attributes()
.get(&static_interned!("href"))
.map(|value| value.to_string())
.as_ref()
.map(String::as_str)
.map(URL::from_str)
.map(|value| URL::parse_with_base(value, Some(document.borrow().url()), None))
.map(Result::ok)
.flatten()
}
Expand Down

0 comments on commit ec85c80

Please sign in to comment.