mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
fix(api): allow hids in uppercase and with dashes; document this
This commit is contained in:
parent
3cefa364b1
commit
bea41ab8a0
2 changed files with 12 additions and 1 deletions
|
|
@ -13,6 +13,15 @@ use crate::auth::AuthState;
|
|||
use crate::{util::json_err, ApiContext};
|
||||
use pluralkit_models::PKSystem;
|
||||
|
||||
// move this somewhere else
|
||||
fn parse_hid(hid: &str) -> String {
|
||||
if hid.len() > 7 || hid.len() < 5 {
|
||||
hid.to_string()
|
||||
} else {
|
||||
hid.to_lowercase().replace("-", "")
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn params(State(ctx): State<ApiContext>, mut req: Request, next: Next) -> Response {
|
||||
let pms = match req.extensions().get::<UrlParams>() {
|
||||
None => Vec::new(),
|
||||
|
|
@ -86,7 +95,7 @@ pub async fn params(State(ctx): State<ApiContext>, mut req: Request, next: Next)
|
|||
Err(_) => sqlx::query_as::<Postgres, PKSystem>(
|
||||
"select * from systems where hid = $1",
|
||||
)
|
||||
.bind(id),
|
||||
.bind(parse_hid(id)),
|
||||
}
|
||||
.fetch_optional(&ctx.db)
|
||||
.await
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue