enum DocumentKind {
HTML,
JavaScript,
}
pub struct Document<'a> {
kind: DocumentKind,
text: &'a str,
}
impl<'a> Document<'a> {
pub fn html(html: &'a str) -> Self {
Document { kind: DocumentKind::HTML, text: html }
}
pub fn js(script: &'a str) -> Self {
Document { kind: DocumentKind::JavaScript, text: script }
}
pub fn urls(&self) -> Vec<&'a str> {
match self.kind {
DocumentKind::HTML => links_html::get_urls_from_html(self.text),
DocumentKind::JavaScript => links_js::get_urls_from_js(self.text)
}
}
}