Skip to content

Commit 95284a2

Browse files
Merge pull request #80 from TryCli-Studio/dev
Fix case sensitivity issues in project slugs and deletion logic
2 parents a0037b4 + 9c7a737 commit 95284a2

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

client/src/pages/create.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ pub fn CreatePage() -> impl IntoView {
213213
<input type="text" class="input-slug"
214214
on:input=move |ev| {
215215
let value = event_target_value(&ev);
216+
let value = value.to_lowercase();
216217
if value.is_empty() || value.chars().all(|c| c.is_ascii_alphanumeric() || c == '-') {
217218
set_slug.set(value);
218219
set_slug_error.set(None);

server/src/handlers/project.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ pub async fn publish_handler(
174174

175175
// 6. Update Database
176176
sqlx::query("INSERT INTO projects (slug, image_tag, markdown, owner_id, owner_username, shell) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (owner_username, slug) DO UPDATE SET image_tag = $2, markdown = $3, shell = $6")
177-
.bind(&payload.slug)
177+
.bind(&safe_slug)
178178
.bind(&new_image_tag)
179179
.bind(&payload.markdown)
180180
.bind(user.id)
@@ -322,7 +322,7 @@ pub async fn delete_project(
322322
let user = user.ok_or((StatusCode::UNAUTHORIZED, "Unauthorized".to_string()))?;
323323

324324
let record: Option<(String,)> = sqlx::query_as(
325-
"SELECT image_tag FROM projects WHERE slug = $1 AND owner_id = $2"
325+
"SELECT image_tag FROM projects WHERE LOWER(slug) = LOWER($1) AND owner_id = $2"
326326
)
327327
.bind(&slug)
328328
.bind(user.id)
@@ -336,7 +336,7 @@ pub async fn delete_project(
336336
};
337337

338338
let db_result = sqlx::query(
339-
"DELETE FROM projects WHERE slug = $1 AND owner_id = $2"
339+
"DELETE FROM projects WHERE LOWER(slug) = LOWER($1) AND owner_id = $2"
340340
)
341341
.bind(&slug)
342342
.bind(user.id)

0 commit comments

Comments
 (0)