fix: make slugs case insensitive
This commit is contained in:
parent
b1df4ce0ed
commit
5597f0057e
1 changed files with 7 additions and 4 deletions
|
@ -133,7 +133,7 @@ async fn view_request(
|
|||
let (ref data, ref tera, ref build_code) = *data.read().await;
|
||||
let entry = match data
|
||||
.query(&SimplifiedQuery {
|
||||
query: AppDataSelectQuery::KeyIs(format!("entries('{}')", slug)),
|
||||
query: AppDataSelectQuery::KeyIs(format!("entries('{}')", slug.to_lowercase())),
|
||||
mode: AppDataSelectMode::One(0),
|
||||
})
|
||||
.await
|
||||
|
@ -236,7 +236,7 @@ async fn editor_request(
|
|||
let (ref data, ref tera, ref build_code) = *data.read().await;
|
||||
let entry = match data
|
||||
.query(&SimplifiedQuery {
|
||||
query: AppDataSelectQuery::KeyIs(format!("entries('{}')", slug)),
|
||||
query: AppDataSelectQuery::KeyIs(format!("entries('{}')", slug.to_lowercase())),
|
||||
mode: AppDataSelectMode::One(0),
|
||||
})
|
||||
.await
|
||||
|
@ -322,7 +322,7 @@ async fn exists_request(
|
|||
message: "Success".to_string(),
|
||||
payload: data
|
||||
.query(&SimplifiedQuery {
|
||||
query: AppDataSelectQuery::KeyIs(format!("entries('{}')", slug)),
|
||||
query: AppDataSelectQuery::KeyIs(format!("entries('{}')", slug.to_lowercase())),
|
||||
mode: AppDataSelectMode::One(0),
|
||||
})
|
||||
.await
|
||||
|
@ -393,6 +393,7 @@ async fn create_request(
|
|||
Json(mut req): Json<CreateEntry>,
|
||||
) -> std::result::Result<impl IntoResponse, Json<ApiReturn<()>>> {
|
||||
let (ref data, _, _) = *data.read().await;
|
||||
req.slug = req.slug.to_lowercase();
|
||||
|
||||
// get real ip
|
||||
let real_ip = headers
|
||||
|
@ -643,7 +644,9 @@ async fn edit_request(
|
|||
}
|
||||
|
||||
// check edited slug and edit code
|
||||
if let Some(new_slug) = req.new_slug {
|
||||
if let Some(mut new_slug) = req.new_slug {
|
||||
new_slug = new_slug.to_lowercase();
|
||||
|
||||
if new_slug.len() < 2 {
|
||||
return Json(Error::DataTooShort("slug".to_string()).into());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue