Merge pull request #30 from Vam-Jam/extension

Parse_id excludes file extension
This commit is contained in:
Raphaël Thériault 2021-02-03 10:34:35 -05:00 committed by GitHub
commit 483273389e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -18,6 +18,9 @@ use std::{fs, path::PathBuf};
/// Parses an ID
fn parse_id(id: &str) -> Result<i32, HttpResponse> {
// Remove any file extension from id
let id = id.split('.').next().unwrap_or_default();
match i32::from_str_radix(id, 36) {
Ok(id) => Ok(id),
Err(_) => Err(HttpResponse::BadRequest().body("Invalid ID")),