fix loading multi-dot extensions

Old slug rules for syntax highlighted pastes did not allow for a
multi-dot paste. This fixes it

Signed-off-by: Gunwant Jain <mail@wantguns.dev>
This commit is contained in:
Gunwant Jain
2022-01-25 15:16:35 +05:30
parent eff3f0dbd6
commit ea144a1024

View File

@@ -9,7 +9,7 @@ pub struct PasteIdSyntax<'a> {
fn valid_syn(syn: &str) -> bool { fn valid_syn(syn: &str) -> bool {
let mut flag = false; let mut flag = false;
let split: Vec<&str> = syn.split('.').collect(); let split: Vec<&str> = syn.split('.').collect();
if split.len() == 2 { if split.len() >= 2 {
for s in split { for s in split {
if s.chars().all(char::is_alphanumeric) { if s.chars().all(char::is_alphanumeric) {
flag = true; flag = true;
@@ -25,7 +25,7 @@ impl<'a> PasteIdSyntax<'a> {
self.syn_id.split('.').collect::<Vec<&str>>()[0] self.syn_id.split('.').collect::<Vec<&str>>()[0]
} }
pub fn get_ext(&self) -> &str { pub fn get_ext(&self) -> &str {
self.syn_id.split('.').collect::<Vec<&str>>()[1] self.syn_id.split_once('.').unwrap().1
} }
} }