Merge pull request #23 from Y2Z/bug-fixes
Allow HTTP redirects and preserve email links
This commit is contained in:
commit
a23cc0b5b1
4 changed files with 6 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "monolith"
|
||||
version = "2.0.5"
|
||||
version = "2.0.6"
|
||||
authors = ["Sunshine <sunshine@uberspace.net>"]
|
||||
description = "CLI tool to save webpages as a single HTML file"
|
||||
|
||||
|
|
|
@ -146,8 +146,8 @@ pub fn walk_and_embed_assets(
|
|||
NodeMatch::Anchor => {
|
||||
for attr in attrs_mut.iter_mut() {
|
||||
if &attr.name.local == "href" {
|
||||
// Do not touch hrefs which begin with a hash sign
|
||||
if attr.value.to_string().chars().nth(0) == Some('#') {
|
||||
// Don't touch email links or hrefs which begin with a hash sign
|
||||
if attr.value.starts_with('#') || attr.value.starts_with("mailto:") {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use regex::Regex;
|
||||
use reqwest::header::{CONTENT_TYPE, USER_AGENT};
|
||||
use reqwest::Client;
|
||||
use reqwest::{Client, RedirectPolicy};
|
||||
use std::time::Duration;
|
||||
use url::{ParseError, Url};
|
||||
use utils::data_to_dataurl;
|
||||
|
@ -75,6 +75,7 @@ pub fn retrieve_asset(
|
|||
Ok(url.to_string())
|
||||
} else {
|
||||
let client = Client::builder()
|
||||
.redirect(RedirectPolicy::limited(3))
|
||||
.timeout(Duration::from_secs(10))
|
||||
.build()
|
||||
.unwrap();
|
||||
|
|
|
@ -22,7 +22,7 @@ fn main() {
|
|||
)
|
||||
.args_from_usage("-j, --no-js 'Excludes JavaScript'")
|
||||
.args_from_usage("-i, --no-images 'Removes images'")
|
||||
.args_from_usage("-u, --user-agent=<Iceweasel> 'Custom User-Agent string'")
|
||||
.args_from_usage("-u, --user-agent=[Iceweasel] 'Custom User-Agent string'")
|
||||
.get_matches();
|
||||
|
||||
// Process the command
|
||||
|
|
Loading…
Reference in a new issue