Skip to content

Commit

Permalink
refactor: update RenderName module to RenderFileName for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
Kremilly committed Aug 18, 2024
1 parent c360ecc commit 5196d42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/render/render_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use crate::{
utils::domains::Domains,
};

pub struct RenderName {
pub domain: String,
pub url_slices: Vec<String>,
pub struct RenderFileName {
domain: String,
url_slices: Vec<String>,
}

impl RenderName {
impl RenderFileName {

pub fn new(url: &str) -> Self {
Self {
Expand All @@ -25,10 +25,10 @@ impl RenderName {

pub fn get_filename(&self) -> String {
match &self.domain {
domain if domain == Uris::PROVIDERS_DOMAINS[2] => self.last_part(3), // github,
domain if domain == Uris::PROVIDERS_DOMAINS[3] => self.last_part(5), // gitlab,
domain if domain == Uris::PROVIDERS_DOMAINS[4] => self.last_part(4), // bitbucket,
domain if domain == Uris::PROVIDERS_DOMAINS[5] => self.last_part(5), // codeberg,
domain if domain == Uris::PROVIDERS_DOMAINS[2] => self.last_part(3), // github
domain if domain == Uris::PROVIDERS_DOMAINS[3] => self.last_part(5), // gitlab
domain if domain == Uris::PROVIDERS_DOMAINS[4] => self.last_part(4), // bitbucket
domain if domain == Uris::PROVIDERS_DOMAINS[5] => self.last_part(5), // codeberg
_ => self.url_slices.last().unwrap().to_string(),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/system/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{

render::{
render_io::RenderIO,
render_name::RenderName,
render_name::RenderFileName,
render_inject::RenderInject,
render_extras::RenderExtras,
},
Expand Down Expand Up @@ -91,7 +91,7 @@ impl Markdown {
let html_content = Self::render(url).await?;
let content = RenderInject::html_content(contents, html_content).await?;

let original_name = RenderName::new(url).get_filename();
let original_name = RenderFileName::new(url).get_filename();
let new_filename = FileUtils::replace_extension(&original_name, "pdf");
let output_path = FileUtils::get_output_path(&path, &new_filename);
let output_path_str = format!("{}{}", &path, &new_filename);
Expand Down

0 comments on commit 5196d42

Please sign in to comment.