Basic redirection working

This commit is contained in:
SinTan1729
2023-04-02 22:26:23 -05:00
parent 0e97516759
commit b9d76b6734
7 changed files with 139 additions and 27 deletions

16
actix/src/utils.rs Normal file
View File

@@ -0,0 +1,16 @@
use crate::database;
use actix_web::web;
use regex::Regex;
pub fn get_longurl(shortlink: web::Path<String>) -> String {
if validate_link(&shortlink) {
database::find_url(shortlink.as_str())
} else {
String::from("")
}
}
fn validate_link(link: &str) -> bool {
let re = Regex::new("[a-z0-9-_]+").unwrap();
re.is_match(link)
}