Skip to content

Commit b68cb9f

Browse files
author
Abhiswant Chaudhary
authored
fix(metassr-html): prevent panic in HtmlPropsBuilder when scripts or styles are not set (#83)
Signed-off-by: Abhiswant Chaudhary <abhiswant0324@gmail.com>
1 parent f054b7e commit b68cb9f

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

crates/metassr-html/src/html_props.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
use std::{
2-
marker::Sized,
3-
path::{Path, PathBuf},
4-
};
1+
use std::path::{Path, PathBuf};
52

6-
#[derive(Debug, Clone)]
3+
#[derive(Debug, Clone, Default)]
74
pub struct HtmlProps {
85
// TODO: getting html language from a config file stored in web application root.
96
pub lang: String,
@@ -65,15 +62,15 @@ impl HtmlPropsBuilder {
6562
body: self.body.as_ref().unwrap_or(&String::new()).to_owned(),
6663
scripts: self
6764
.scripts
68-
.as_ref()
69-
.unwrap()
65+
.as_deref()
66+
.unwrap_or(&[])
7067
.iter()
7168
.map(|p| Path::new(p).to_path_buf())
7269
.collect(),
7370
styles: self
7471
.styles
75-
.as_ref()
76-
.unwrap()
72+
.as_deref()
73+
.unwrap_or(&[])
7774
.iter()
7875
.map(|p| Path::new(p).to_path_buf())
7976
.collect(),

0 commit comments

Comments
 (0)