Skip to content

Commit

Permalink
fix: fixed open variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Kremilly committed Jun 12, 2024
1 parent a9453a1 commit 7a03e4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/syntax/vars_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ impl VarsBlock {
let open_pattern = Regex::new(BlocksRegExp::GET_OPEN_VAR).unwrap();

if let Some(caps) = open_pattern.captures(&contents) {
caps.get(1).map(|m| m.as_str().to_string())
let url = caps.get(1).map(|m| m.as_str().to_string())?;
open::that(&url).unwrap();

None
} else {
None
}
Expand Down
5 changes: 3 additions & 2 deletions src/system/pdf.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use lopdf::Document;
use indicatif::ProgressBar;
use reqwest::header::CONTENT_TYPE as MimeType;

use std::{
error::Error,
Expand Down Expand Up @@ -36,14 +37,14 @@ pub struct Pdf;
impl Pdf {

pub async fn is_pdf_file(url: &str) -> Result<bool, Box<dyn Error>> {
let client: reqwest::Client = reqwest::Client::new();
let client = reqwest::Client::new();
let response = client.get(url).send().await?;

if !response.status().is_success() {
return Ok(false);
}

if let Some(content_type) = response.headers().get(reqwest::header::CONTENT_TYPE) {
if let Some(content_type) = response.headers().get(MimeType) {
if let Ok(content_type_str) = content_type.to_str() {
if content_type_str == "application/pdf" {
return Ok(true);
Expand Down

0 comments on commit 7a03e4a

Please sign in to comment.