paste: make URL regex case insensitive
Signed-off-by: ATechnoHazard <amolele@gmail.com>
This commit is contained in:
parent
2a3634e5de
commit
ebe7bf4594
@ -1,12 +1,12 @@
|
||||
use anyhow::Result;
|
||||
use diesel::pg::PgConnection;
|
||||
use regex::Regex;
|
||||
use regex::RegexBuilder;
|
||||
|
||||
use super::entity::Paste;
|
||||
use super::postgres;
|
||||
|
||||
pub fn create_paste(paste: &mut Paste, conn: &PgConnection) -> Result<usize> {
|
||||
let re = Regex::new("^(https?://)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(:\\d+)?(/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(#[-a-z\\d_]*)?$").unwrap();
|
||||
let re = RegexBuilder::new("^(https?://)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(:\\d+)?(/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(#[-a-z\\d_]*)?$").case_insensitive(true).build().unwrap();
|
||||
paste.is_url = Some(re.is_match(&*paste.content.clone()));
|
||||
postgres::create_paste(paste, conn)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user