-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add support for github repository name in markdown render
- Loading branch information
Showing
4 changed files
with
37 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use crate::{ | ||
consts::uris::Uris, | ||
|
||
utils::{ | ||
url::UrlMisc, | ||
domains::Domains, | ||
}, | ||
}; | ||
|
||
pub struct FileName; | ||
|
||
impl FileName { | ||
|
||
fn github_repo_name(url: &str) -> String { | ||
let segments: Vec<&str> = url.split('/').collect(); | ||
let repo_name = segments[segments.len() - 3]; | ||
repo_name.to_string() | ||
} | ||
|
||
pub fn get_final_name(url: &str) -> String { | ||
let domain = Domains::get(url); | ||
|
||
match domain.as_str() { | ||
domain if domain == Uris::PROVIDERS_DOMAINS[2] => Self::github_repo_name(url), | ||
_ => UrlMisc::get_last_part(url), | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ pub mod file; | |
pub mod remote; | ||
pub mod base64; | ||
pub mod domains; | ||
pub mod filename; | ||
pub mod validation; |